-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add Github workflow and rework docker file (#3)
- Loading branch information
1 parent
5edef37
commit 53a9ef3
Showing
2 changed files
with
56 additions
and
37 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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" ] |