Skip to content

Commit

Permalink
chore: add docker configuration and workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
H1ghBre4k3r committed Nov 2, 2024
1 parent 23617b8 commit c2c9fec
Show file tree
Hide file tree
Showing 4 changed files with 110 additions and 0 deletions.
34 changes: 34 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# Include any files or directories that you don't want to be copied to your
# container here (e.g., local build artifacts, temporary files, etc.).
#
# For more help, visit the .dockerignore file reference guide at
# https://docs.docker.com/go/build-context-dockerignore/

**/.classpath
**/.dockerignore
**/.env
**/.git
**/.gitignore
**/.project
**/.settings
**/.toolstarget
**/.vs
**/.vscode
**/.next
**/.cache
**/*.*proj.user
**/*.dbmdl
**/*.jfm
**/charts
**/docker-compose*
**/compose*
**/Dockerfile*
**/node_modules
**/npm-debug.log
**/obj
**/secrets.dev.yaml
**/values.dev.yaml
**/build
**/dist
LICENSE
README.md
5 changes: 5 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,8 @@ jobs:
run: npm run build
- name: Lint the project
run: npm run lint

image:
needs: build
uses: ./.github/workflows/image.yml
secrets: inherit
42 changes: 42 additions & 0 deletions .github/workflows/image.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
name: Image

on:
workflow_call:

jobs:
publish-docker-image:
name: Build & Publish Docker Image
runs-on: self-hosted

steps:
- uses: actions/checkout@v3

- name: Set up QEMU
uses: docker/setup-qemu-action@v2

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2

- name: Login to GitHub Container Registry
uses: docker/login-action@v2
if: ${{ github.ref_name == 'main' }}
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GH_PAT }}

- name: Set lower case owner name
run: |
echo "OWNER_LC=${OWNER,,}" >>${GITHUB_ENV}
env:
OWNER: "${{ github.repository_owner }}"

- name: Build and Push Docker Image
uses: docker/build-push-action@v3
with:
platforms: linux/amd64,linux/arm64/v8
context: .
push: ${{ github.ref_name == 'main' }}
tags: |
ghcr.io/${{ env.OWNER_LC }}/kneipolympics:latest
ghcr.io/${{ env.OWNER_LC }}/kneipolympics:${{ github.sha }}
29 changes: 29 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
ARG NODE_VERSION=20.16.0

FROM node:${NODE_VERSION}-alpine as base

WORKDIR /usr/src/app

FROM base as deps

RUN --mount=type=bind,source=package.json,target=package.json \
--mount=type=bind,source=package-lock.json,target=package-lock.json \
--mount=type=cache,target=/root/.npm \
npm ci --omit=dev

FROM deps as build

RUN --mount=type=bind,source=package.json,target=package.json \
--mount=type=bind,source=package-lock.json,target=package-lock.json \
--mount=type=cache,target=/root/.npm \
npm ci

COPY . .

RUN npm run build

FROM nginx:1.27 as final

LABEL org.opencontainers.image.source="https://github.com/pesca-dev/kneipolympics"

COPY --from=build /usr/src/app/dist /usr/share/nginx/html

0 comments on commit c2c9fec

Please sign in to comment.