diff --git a/docker/Dockerfile b/docker/Dockerfile index b158234..7b6c0f5 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -30,13 +30,20 @@ RUN apk add --no-cache libc6-compat RUN apk update WORKDIR /app - # First install the dependencies (as they change less often) COPY .gitignore .gitignore COPY --from=builder /app/out/json/ . COPY --from=builder /app/out/pnpm-lock.yaml ./pnpm-lock.yaml RUN --mount=type=cache,id=pnpm,target=/pnpm/store pnpm install --frozen-lockfile +# Build arguments for version information +# Placed after install to preserve dependency cache when version changes +ARG APP_VERSION=unknown +ARG GIT_SHA=unknown + +# Set version as environment variables for Next.js build +ENV NEXT_PUBLIC_APP_VERSION=$APP_VERSION +ENV NEXT_PUBLIC_GIT_SHA=$GIT_SHA # Build the project COPY --from=builder /app/out/full/ . @@ -46,14 +53,6 @@ RUN pnpm turbo run build --filter=web... FROM base AS runner WORKDIR /app -# Build arguments for version information -ARG APP_VERSION=unknown -ARG GIT_SHA=unknown - -# Set version as environment variables -ENV NEXT_PUBLIC_APP_VERSION=$APP_VERSION -ENV NEXT_PUBLIC_GIT_SHA=$GIT_SHA - COPY --from=installer /app/apps/web/next.config.js . COPY --from=installer /app/apps/web/package.json . COPY --from=installer /app/pnpm-lock.yaml .