From 5ecef67855e98b293d9ae659023a99df347a9631 Mon Sep 17 00:00:00 2001 From: Enrico Ros Date: Mon, 26 Feb 2024 23:24:12 -0800 Subject: [PATCH] GA: Docker and GitHub actions support --- .dockerignore | 5 +++++ .github/workflows/docker-image.yml | 3 ++- Dockerfile | 7 +++++++ 3 files changed, 14 insertions(+), 1 deletion(-) diff --git a/.dockerignore b/.dockerignore index c9299b335a..2ae7123219 100644 --- a/.dockerignore +++ b/.dockerignore @@ -1,7 +1,12 @@ # big-AGI non-code files /docs/ +/dist/ README.md +# Ignore build and log files +Dockerfile +/.dockerignore + # Node build artifacts /node_modules /.pnp diff --git a/.github/workflows/docker-image.yml b/.github/workflows/docker-image.yml index c3236638b0..dd81efd268 100644 --- a/.github/workflows/docker-image.yml +++ b/.github/workflows/docker-image.yml @@ -57,4 +57,5 @@ jobs: file: Dockerfile push: true tags: ${{ steps.meta.outputs.tags }} - labels: ${{ steps.meta.outputs.labels }} \ No newline at end of file + labels: ${{ steps.meta.outputs.labels }} + build-args: NEXT_PUBLIC_GA4_MEASUREMENT_ID=${{ secrets.GA4_MEASUREMENT_ID }} \ No newline at end of file diff --git a/Dockerfile b/Dockerfile index e389912076..f4c60af0de 100644 --- a/Dockerfile +++ b/Dockerfile @@ -2,6 +2,7 @@ FROM node:18-alpine AS base ENV NEXT_TELEMETRY_DISABLED 1 + # Dependencies FROM base AS deps WORKDIR /app @@ -14,10 +15,15 @@ COPY src/server/prisma ./src/server/prisma ENV NODE_ENV development RUN npm ci + # Builder FROM base AS builder WORKDIR /app +# Optional argument to configure GA4 at build time (see: docs/deploy-analytics.md) +ARG NEXT_PUBLIC_GA4_MEASUREMENT_ID +ENV NEXT_PUBLIC_GA4_MEASUREMENT_ID=${NEXT_PUBLIC_GA4_MEASUREMENT_ID} + # Copy development deps and source COPY --from=deps /app/node_modules ./node_modules COPY . . @@ -29,6 +35,7 @@ RUN npm run build # Reduce installed packages to production-only RUN npm prune --production + # Runner FROM base AS runner WORKDIR /app