Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Github workflow and rework Docker file #3

Merged
merged 1 commit into from
Feb 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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/build-push-action@v4.0.0
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" ]
Loading