diff --git a/.github/workflows/staging-deploy.yml b/.github/workflows/staging-deploy.yml new file mode 100644 index 000000000..bf354c6ec --- /dev/null +++ b/.github/workflows/staging-deploy.yml @@ -0,0 +1,46 @@ +name: Staging deploy + +on: + push: + branches: ["develop"] + +jobs: + docker-build-and-push: + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Log in to GitHub Container Registry + uses: docker/login-action@v3 + with: + registry: ghcr.io + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Build Client Docker image + run: | + docker build \ + -t ghcr.io/bluewave-labs/checkmate-frontend:staging \ + -f ./docker/staging/server.Dockerfile \ + --label org.opencontainers.image.source=https://github.com/bluewave-labs/checkmate \ + . + + - name: Push Client Docker image + run: docker push ghcr.io/bluewave-labs/checkmate-frontend:staging + + deploy-to-staging: + needs: docker-build-and-push + runs-on: ubuntu-latest + steps: + - name: SSH into server and restart container using Docker Compose + uses: appleboy/ssh-action@v1.0.0 + with: + host: ${{ secrets.STAGING_SERVER_HOST }} + username: ${{ secrets.STAGING_SERVER_USER }} + key: ${{ secrets.STAGING_SERVER_SSH_KEY }} + script: | + cd checkmate/server/docker/staging + docker compose down + docker compose pull + docker compose up -d diff --git a/docker/staging/client.Dockerfile b/docker/staging/client.Dockerfile new file mode 100644 index 000000000..9eeedca5b --- /dev/null +++ b/docker/staging/client.Dockerfile @@ -0,0 +1,30 @@ +FROM node:20-alpine AS build + +ENV NODE_OPTIONS="--max-old-space-size=4096" + +WORKDIR /app + +RUN apk add --no-cache \ + python3 \ + make g++ \ + gcc \ + libc-dev \ + linux-headers \ + libusb-dev \ + eudev-dev + + +COPY package*.json ./ + +RUN npm install + +COPY . ./ + +RUN npm run build + +FROM nginx:1.27.1-alpine + +COPY --from=build /app/dist /usr/share/nginx/html +COPY --from=build /app/env.sh /docker-entrypoint.d/env.sh +RUN chmod +x /docker-entrypoint.d/env.sh +CMD ["nginx", "-g", "daemon off;"] \ No newline at end of file