From 9c6a0b7c75d638c999cb9d7f247aeac7e49fb15b Mon Sep 17 00:00:00 2001 From: Ricardo Alcantara Date: Tue, 3 Mar 2026 12:05:41 +0000 Subject: [PATCH] Add Dockerfile and GitHub Actions workflow for Docker build --- .github/workflows/docker.yml | 30 ++++++++++++++++++++++++++++++ Dockerfile | 25 +++++++++++++++++++++++++ 2 files changed, 55 insertions(+) create mode 100644 .github/workflows/docker.yml create mode 100644 Dockerfile diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml new file mode 100644 index 0000000..a4041b3 --- /dev/null +++ b/.github/workflows/docker.yml @@ -0,0 +1,30 @@ +name: Docker + +on: + push: + branches: + - main + +jobs: + build-and-push: + runs-on: ubuntu-latest + permissions: + contents: read + packages: write + + steps: + - uses: actions/checkout@v4 + + - name: Log in to GHCR + uses: docker/login-action@v3 + with: + registry: ghcr.io + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Build and push + uses: docker/build-push-action@v6 + with: + context: . + push: true + tags: ghcr.io/${{ github.repository }}:latest diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..56ac718 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,25 @@ +# ── Stage 1: build ───────────────────────────────────────────── +FROM node:20-alpine AS build +WORKDIR /app + +COPY package*.json ./ +RUN npm install + +COPY . . +RUN npm run build + +# ── Stage 2: serve ───────────────────────────────────────────── +FROM nginx:alpine + +COPY --from=build /app/dist /usr/share/nginx/html + +RUN printf 'server {\n\ + listen 80;\n\ + root /usr/share/nginx/html;\n\ + index index.html;\n\ + location / {\n\ + try_files $uri $uri/ /index.html;\n\ + }\n\ +}\n' > /etc/nginx/conf.d/default.conf + +EXPOSE 80