Skip to content

Commit

Permalink
Add Github workflow and rework docker file (#3)
Browse files Browse the repository at this point in the history
  • Loading branch information
Oscariremma authored Feb 17, 2024
1 parent 5edef37 commit 53a9ef3
Show file tree
Hide file tree
Showing 2 changed files with 56 additions and 37 deletions.
45 changes: 45 additions & 0 deletions .github/workflows/armit.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
name: ArmIT
on:
push:
branches: [main]
pull_request:
branches: [main]
jobs:
build:
name: Build

runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Use Node.js 20
uses: actions/setup-node@v3
with:
node-version: 20
- run: npm install --frozen-lockfile
- run: npm run build

docker:
name: Build docker container

permissions:
packages: write

needs: [build]
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Login to GitHub Container Registry
if: ${{ github.ref == 'refs/heads/main' }}
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build Docker image (and push on main)
uses: docker/[email protected]
with:
push: ${{ github.ref == 'refs/heads/main' }}
tags: ghcr.io/cthit/armit:latest
48 changes: 11 additions & 37 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,42 +1,16 @@
# Use an official Node.js image as a base image
FROM node:18-alpine

# Set the working directory inside the container
FROM node:20-alpine AS builder
WORKDIR /app

# Copy package.json and package-lock.json to the working directory
COPY package*.json ./

# Install dependencies
RUN npm install

# Copy the rest of the application code to the working directory
COPY package*.json .
RUN npm ci
COPY . .

# Build the SvelteKit app with Vite
RUN npm run build
RUN npm prune --production

#Expose port
FROM node:20-alpine
WORKDIR /app
COPY --from=builder /app/build build/
COPY --from=builder /app/node_modules node_modules/
COPY package.json .
EXPOSE 3000

#Start the app
CMD ["npm", "run", "preview"]


#Should the above not work, use this:

# FROM node:17-alpine

# WORKDIR /app

# COPY package*.json ./

# RUN npm install --legacy-peer-deps

# COPY . .

# RUN npm run build

# EXPOSE 3000

# CMD ["npm", "run", "dev"]
ENV NODE_ENV=production
CMD [ "node", "build" ]

0 comments on commit 53a9ef3

Please sign in to comment.