From 812f0f6255f244d1b090fcdff72f8588ce9671e2 Mon Sep 17 00:00:00 2001 From: Xavier Frankline Date: Fri, 15 Nov 2024 18:18:27 +0300 Subject: [PATCH] chore: update Dockerfile set Next build time envs --- .github/workflows/main.yml | 6 ------ Dockerfile | 20 ++++++++++++++------ 2 files changed, 14 insertions(+), 12 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 81a43270..5576cf39 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -15,9 +15,6 @@ env: DOKKU_REMOTE_URL: "ssh://dokku@ui-2.prod.codeforafrica.org/sensors-africa-ui" NEXT_PUBLIC_APP_URL: "https://sensors.africa" NEXT_PUBLIC_APP_API_BASE_URL: "https://api.sensors.africa/v2" - NEXT_PUBLIC_APP_API_DOCS_URL: "https://api.sensors.africa/docs" - NEXT_PUBLIC_APP_API_STATIC_URL: "https://api.sensors.africa/static/v2" - NEXT_PUBLIC_APP_MAP_URL: "https://v2.map.aq.sensors.africa/" IMAGE_NAME: "codeforafrica/sensors-africa-ui" VERSION_FILE_NAME: "package.json" @@ -86,9 +83,6 @@ jobs: build-args: | NEXT_PUBLIC_APP_URL=${{ env.NEXT_PUBLIC_APP_URL }} NEXT_PUBLIC_APP_API_BASE_URL=${{ env.NEXT_PUBLIC_APP_API_BASE_URL }} - NEXT_PUBLIC_APP_API_DOCS_URL=${{ env.NEXT_PUBLIC_APP_API_DOCS_URL }} - NEXT_PUBLIC_API_STATIC_URL=${{ env.NEXT_PUBLIC_APP_API_STATIC_URL }} - NEXT_PUBLIC_APP_MAP_URL=${{ env.NEXT_PUBLIC_APP_MAP_URL }} GOOGLE_ANALYTICS_ID=${{ secrets.SENSORS_AFRICA_GA_ANALYTICS_ID }} API_TOKEN=${{ secrets.SENSORS_AFRICA_API_TOKEN }} cache-from: type=local,src=/tmp/.buildx-cache diff --git a/Dockerfile b/Dockerfile index ff0edaa6..6bf41684 100644 --- a/Dockerfile +++ b/Dockerfile @@ -3,12 +3,11 @@ ARG \ # Next.js collects completely anonymous telemetry data about general usage. # Learn more here: https://nextjs.org/telemetry NEXT_TELEMETRY_DISABLED=1 - # ============================================================================ # Node # ============================================================================ -FROM node:20.14-alpine as node +FROM node:20.14-alpine AS node # Always install security updated e.g. https://pythonspeed.com/articles/security-updates-in-docker/ # Update local cache so that other stages don't need to update cache @@ -19,7 +18,7 @@ RUN apk update \ # Node # ============================================================================ # -FROM node as deps +FROM node AS deps # Check https://github.com/nodejs/docker-node/tree/b4117f9333da4138b03a546ec926ef50a31506c3#nodealpine to understand why libc6-compat might be needed. RUN apk add --no-cache libc6-compat WORKDIR /app @@ -36,8 +35,17 @@ WORKDIR /app COPY --from=deps /app/node_modules ./node_modules COPY . . -ARG NEXT_TELEMETRY_DISABLED -ENV NEXT_TELEMETRY_DISABLED=${NEXT_TELEMETRY_DISABLED} +ARG NEXT_TELEMETRY_DISABLED\ + NEXT_PUBLIC_APP_URL \ + NEXT_PUBLIC_APP_API_BASE_URL \ + GOOGLE_ANALYTICS_ID \ + API_TOKEN + +ENV NEXT_TELEMETRY_DISABLED=${NEXT_TELEMETRY_DISABLED}\ + NEXT_PUBLIC_APP_URL=${NEXT_PUBLIC_APP_URL} \ + NEXT_PUBLIC_APP_API_BASE_URL=${NEXT_PUBLIC_APP_API_BASE_URL} \ + GOOGLE_ANALYTICS_ID=${GOOGLE_ANALYTICS_ID} \ + API_TOKEN=${API_TOKEN} RUN yarn build @@ -67,7 +75,7 @@ RUN set -ex \ COPY --from=builder /app/public ./public -# Automatically leverage output traces to reduce image size +# Automatically leverage output traces to reduce image size # https://nextjs.org/docs/advanced-features/output-file-tracing COPY --from=builder --chown=nextjs:nodejs /app/.next/standalone ./ COPY --from=builder --chown=nextjs:nodejs /app/.next/static ./.next/static