From 6796f168131fd49bb3b60457a865ebdbdd4e4bc2 Mon Sep 17 00:00:00 2001 From: Hayden Hargreaves Date: Sat, 25 Apr 2026 15:04:25 -0700 Subject: [PATCH] cicd: trying to build web app --- .github/workflows/web-image.yml | 49 +++++++++++++++++++++++++++++++++ web/Dockerfile | 18 ++++++++++++ web/nginx.conf | 10 +++++++ 3 files changed, 77 insertions(+) create mode 100644 .github/workflows/web-image.yml create mode 100644 web/Dockerfile create mode 100644 web/nginx.conf diff --git a/.github/workflows/web-image.yml b/.github/workflows/web-image.yml new file mode 100644 index 0000000..1b285e7 --- /dev/null +++ b/.github/workflows/web-image.yml @@ -0,0 +1,49 @@ +name: Build and push web image + +on: + push: + branches: + - master + workflow_dispatch: + +permissions: + contents: read + packages: write + +jobs: + build-and-push: + runs-on: ubuntu-latest + + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + + - name: Log in to GHCR + uses: docker/login-action@v3 + with: + registry: ghcr.io + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Extract metadata + id: meta + uses: docker/metadata-action@v5 + with: + images: ghcr.io/${{ github.repository_owner }}/termtap-web + tags: | + type=sha + type=raw,value=latest + + - name: Build and push + uses: docker/build-push-action@v6 + with: + context: ./web + file: ./web/Dockerfile + push: true + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} + cache-from: type=gha + cache-to: type=gha,mode=max diff --git a/web/Dockerfile b/web/Dockerfile new file mode 100644 index 0000000..87d6e34 --- /dev/null +++ b/web/Dockerfile @@ -0,0 +1,18 @@ +FROM node:22-alpine AS build + +WORKDIR /app + +COPY package*.json ./ +RUN npm ci + +COPY . . +RUN npm run build + +FROM nginx:1.27-alpine + +COPY nginx.conf /etc/nginx/conf.d/default.conf +COPY --from=build /app/dist /usr/share/nginx/html + +EXPOSE 80 + +CMD ["nginx", "-g", "daemon off;"] diff --git a/web/nginx.conf b/web/nginx.conf new file mode 100644 index 0000000..0eea1de --- /dev/null +++ b/web/nginx.conf @@ -0,0 +1,10 @@ +server { + listen 80; + server_name _; + root /usr/share/nginx/html; + index index.html; + + location / { + try_files $uri $uri/ /index.html; + } +}