diff --git a/.github/workflows/deploy_image.yml b/.github/workflows/deploy_image.yml new file mode 100644 index 0000000..dcb64b1 --- /dev/null +++ b/.github/workflows/deploy_image.yml @@ -0,0 +1,42 @@ +name: Deploy app image + +on: + push: + branches: + - main + workflow_dispatch: + +# Defines two custom environment variables for the workflow. These are used for the Container registry domain, and a name for the Docker image that this workflow builds. +env: + REGISTRY: ghcr.io + IMAGE_NAME: accommodus/foodstoragemanager/app + +# There is a single job in this workflow. It's configured to run on the latest available version of Ubuntu. +jobs: + build-and-push-image: + runs-on: ubuntu-latest + # Sets the permissions granted to the `GITHUB_TOKEN` for the actions in this job. + permissions: + contents: read + packages: write + attestations: write + id-token: write + # + steps: + # Uses the `docker/login-action` action to log in to the Container registry registry using the account and password that will publish the packages. Once published, the packages are scoped to the account defined here. + - name: Log in to the Container registry + uses: docker/login-action@v3 + with: + registry: ${{ env.REGISTRY }} + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + - name: Set up QEMU for multi-architecture builds + uses: docker/setup-qemu-action@v3 + - name: Setup Docker buildx for multi-architecture builds + uses: docker/setup-buildx-action@v3 + - name: Build and push + uses: docker/build-push-action@v6 + with: + platforms: linux/amd64,linux/arm64 + push: true + tags: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:latest diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..5938427 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,28 @@ +FROM node:22-bookworm-slim AS build + +WORKDIR /app +ADD https://github.com/Accommodus/FoodStorageManager.git . + +RUN rm -f package-lock.json && npm install +RUN npm run build + +FROM node:22-bookworm-slim AS runtime + +WORKDIR /app +ENV NODE_ENV=production +ENV S_PORT=3000 + +# Manifests so npm can install production deps for the workspaces +COPY --from=build /app/package.json /app/package-lock.json ./ +COPY --from=build /app/server/package.json /app/server/package.json +COPY --from=build /app/client/package.json /app/client/package.json +COPY --from=build /app/schema/package.json /app/schema/package.json + +# Install only prod deps +RUN npm ci --omit=dev + +COPY --from=build /app/server/dist ./server/dist +COPY --from=build /app/client/dist ./client/dist + +EXPOSE 3000 +CMD ["npm", "--workspace=server", "run", "start"]