Skip to content

Commit

Permalink
chore: update Dockerfile set Next build time envs
Browse files Browse the repository at this point in the history
  • Loading branch information
thepsalmist committed Nov 15, 2024
1 parent 2aa3ce0 commit 812f0f6
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 12 deletions.
6 changes: 0 additions & 6 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,6 @@ env:
DOKKU_REMOTE_URL: "ssh://[email protected]/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"

Expand Down Expand Up @@ -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
Expand Down
20 changes: 14 additions & 6 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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

Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 812f0f6

Please sign in to comment.