From 519fbe3dd0be7baf94e4122a39f0394a2f4da1ba Mon Sep 17 00:00:00 2001 From: Debian Date: Wed, 20 Aug 2025 15:50:16 +0000 Subject: [PATCH] Add Dockerfile and CI --- .github/workflows/build.yml | 30 ++++++++++++++++++++++++++++++ Dockerfile | 20 ++++++++++++++++++++ 2 files changed, 50 insertions(+) create mode 100644 .github/workflows/build.yml create mode 100644 Dockerfile diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 0000000..e5fab6d --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,30 @@ +name: build-and-push +on: + push: + branches: [ "main" ] +permissions: + contents: read + packages: write +jobs: + docker: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: docker/setup-buildx-action@v3 + - uses: docker/login-action@v3 + with: + registry: ghcr.io + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + - uses: docker/metadata-action@v5 + id: meta + with: + images: ghcr.io/${{ github.repository }} + tags: | + type=raw,value=main + type=sha,format=short + - uses: docker/build-push-action@v6 + with: + push: true + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..47474f2 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,20 @@ +# syntax=docker/dockerfile:1 +FROM node:20-alpine AS build +WORKDIR /app +COPY package*.json ./ +RUN npm ci +COPY . . +RUN npm run build + +FROM nginx:1.27-alpine +COPY --from=build /app/dist /usr/share/nginx/html +# Serve SPA on port 3000 with history fallback +RUN printf 'server { \ + listen 3000; \ + server_name _; \ + root /usr/share/nginx/html; \ + index index.html; \ + location / { try_files $uri /index.html; } \ +}\n' > /etc/nginx/conf.d/default.conf +EXPOSE 3000 +CMD ["nginx","-g","daemon off;"]