Skip to content

Commit

Permalink
refactoring: Use build-arg-file during client docker build
Browse files Browse the repository at this point in the history
  • Loading branch information
martintomas committed Dec 6, 2023
1 parent d2a2953 commit 5912617
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 3 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ jobs:
env:
IMAGE_NAME: ${{ env.PROJECT_NAME }}-${{ steps.extract_branch.outputs.branch == 'main' && 'production' || 'staging' }}-client
run: |
docker build --build-arg NEXT_PUBLIC_BASE_PATH=/impact-sphere -f client/Dockerfile.prod -t $IMAGE_REGISTRY/$IMAGE_NAME:$GITHUB_SHA .
docker build --build-arg-file client/.env.local -f client/Dockerfile.prod -t $IMAGE_REGISTRY/$IMAGE_NAME:$GITHUB_SHA .
- name: Install doctl
uses: digitalocean/action-doctl@v2
Expand Down
25 changes: 23 additions & 2 deletions client/Dockerfile.prod
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,25 @@ RUN apt-get update -y && \
apt-get install -y libc6 && \
apt-get clean

ARG NEXT_PUBLIC_URL
ARG NEXT_PUBLIC_BASE_PATH
ENV NEXT_PUBLIC_BASE_PATH=$NEXT_PUBLIC_BASE_PATH
ARG NEXT_PUBLIC_ENVIRONMENT
ARG NEXT_PUBLIC_API_URL
ARG NEXT_PUBLIC_GA_TRACKING_ID
ARG NEXT_PUBLIC_MAPBOX_API_TOKEN
ARG LOG_LEVEL
ARG RECOIL_DUPLICATE_ATOM_KEY_CHECKING_ENABLED

ENV NODE_ENV production
ENV NEXT_TELEMETRY_DISABLED 1
ENV NEXT_PUBLIC_URL=$NEXT_PUBLIC_URL
ENV NEXT_PUBLIC_BASE_PATH=$NEXT_PUBLIC_BASE_PATH
ENV NEXT_PUBLIC_ENVIRONMENT=$NEXT_PUBLIC_ENVIRONMENT
ENV NEXT_PUBLIC_API_URL=$NEXT_PUBLIC_API_URL
ENV NEXT_PUBLIC_GA_TRACKING_ID=$NEXT_PUBLIC_GA_TRACKING_ID
ENV NEXT_PUBLIC_MAPBOX_API_TOKEN=$NEXT_PUBLIC_MAPBOX_API_TOKEN
ENV LOG_LEVEL=$LOG_LEVEL
ENV RECOIL_DUPLICATE_ATOM_KEY_CHECKING_ENABLED=$RECOIL_DUPLICATE_ATOM_KEY_CHECKING_ENABLED

WORKDIR /app
COPY .yarn ./.yarn
Expand All @@ -28,6 +42,14 @@ RUN yarn build
FROM node:18.15.0-bullseye-slim AS runner
ENV NODE_ENV production
ENV NEXT_TELEMETRY_DISABLED 1
ENV NEXT_PUBLIC_URL=$NEXT_PUBLIC_URL
ENV NEXT_PUBLIC_BASE_PATH=$NEXT_PUBLIC_BASE_PATH
ENV NEXT_PUBLIC_ENVIRONMENT=$NEXT_PUBLIC_ENVIRONMENT
ENV NEXT_PUBLIC_API_URL=$NEXT_PUBLIC_API_URL
ENV NEXT_PUBLIC_GA_TRACKING_ID=$NEXT_PUBLIC_GA_TRACKING_ID
ENV NEXT_PUBLIC_MAPBOX_API_TOKEN=$NEXT_PUBLIC_MAPBOX_API_TOKEN
ENV LOG_LEVEL=$LOG_LEVEL
ENV RECOIL_DUPLICATE_ATOM_KEY_CHECKING_ENABLED=$RECOIL_DUPLICATE_ATOM_KEY_CHECKING_ENABLED

WORKDIR /app

Expand All @@ -39,7 +61,6 @@ COPY --from=build --chown=nextjs:nodejs /app/client/entrypoint.sh ./entrypoint.s
COPY --from=build /app/node_modules ./node_modules
COPY --from=build /app/client/public ./public
COPY --from=build /app/client/package.json ./package.json
COPY --from=build /app/client/.env.local ./.env.local

USER nextjs

Expand Down

0 comments on commit 5912617

Please sign in to comment.