Skip to content

Commit

Permalink
Update dockerfile
Browse files Browse the repository at this point in the history
  • Loading branch information
kelvinkipruto committed Jul 5, 2024
1 parent 94d6df8 commit 61eedab
Show file tree
Hide file tree
Showing 3 changed files with 99 additions and 100 deletions.
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
name: Hurumap | Deploy | DEV
name: Climate Mapped Africa | Deploy | DEV

on:
push:
branches: [ft/hurumap-setup]
paths:
- "apps/hurumap/**"
- "Dockerfile.hurumap"
- ".github/workflows/hurumap-deploy-dev.yml"
- "apps/climatemapped-africa/**"
- "Dockerfile"
- ".github/workflows/climatemapped-africa-deploy-dev.yml"

concurrency:
group: "${{ github.workflow }} @ ${{ github.ref }}"
Expand All @@ -15,10 +15,10 @@ concurrency:
env:
DOKKU_REMOTE_BRANCH: "master"
DOKKU_REMOTE_URL: "ssh://[email protected]"
IMAGE_NAME: "codeforafrica/hurumap-ui"
NEXT_PUBLIC_APP_URL: "https://hurumap-ui.dev.codeforafrica.org"
IMAGE_NAME: "codeforafrica/climatemapped-africa-ui"
NEXT_PUBLIC_APP_URL: "https://climatemapped-africa-ui.dev.codeforafrica.org"
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
APP_NAME: hurumap-ui
APP_NAME: climatemapped-africa-ui

jobs:
deploy:
Expand Down Expand Up @@ -58,7 +58,7 @@ jobs:
cache-from: type=local,src=/tmp/.buildx-cache
cache-to: type=local,dest=/tmp/.buildx-cache-new
context: .
file: Dockerfile.hurumap
target: climatemapped-africa-runner
push: true
tags: "${{ env.IMAGE_NAME }}:${{ github.sha }}"

Expand Down
91 changes: 91 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -596,3 +596,94 @@ USER nextjs
# server.js is created by next build from the standalone output
# https://nextjs.org/docs/pages/api-reference/next-config-js/output
CMD ["node", "apps/vpnmanager/server.js"]



# ============================================================================
# Climate Mapped Africa
# ============================================================================

#
# climatemapped-africa-desp: image with all climatemapped-africa dependencies
# ---------------------------------------------------

FROM base-deps as climatemapped-africa-deps

COPY apps/climatemapped-africa/package.json ./apps/climatemapped-africa/package.json

# Use virtual store: https://pnpm.io/cli/fetch#usage-scenario
RUN pnpm --filter "./apps/climatemapped-africa" install --offline --frozen-lockfile

#
# climatemapped-africa-builder: image that uses deps to build shippable output
# ----------------------------------------------------------------

FROM base-builder as climatemapped-africa-builder

ARG NEXT_TELEMETRY_DISABLED \
# Next.js / Payload (build time)
PORT \
# Next.js (runtime)
NEXT_PUBLIC_APP_NAME=Climate Mapped Africa \
NEXT_PUBLIC_APP_URL \
NEXT_PUBLIC_SENTRY_DSN \
NEXT_PUBLIC_SEO_DISABLED \
NEXT_PUBLIC_IMAGE_DOMAINS="cms.dev.codeforafrica.org,hurumap-v2.s3.amazonaws.com" \
NEXT_PUBLIC_IMAGE_SCALE_FACTOR=2 \
NEXT_PUBLIC_GOOGLE_ANALYTICS \
# Sentry (build time)
SENTRY_AUTH_TOKEN \
SENTRY_ENVIRONMENT \
SENTRY_ORG \
SENTRY_PROJECT \
# Custom (runtime)
HURUMAP_API_URL

# This is in app-builder instead of base-builder just incase app-deps adds deps
COPY --from=climatemapped-africa-deps /workspace/node_modules ./node_modules

COPY --from=climatemapped-africa-deps /workspace/apps/climatemapped-africa/node_modules ./apps/climatemapped-africa/node_modules

COPY apps/climatemapped-africa ./apps/climatemapped-africa

RUN pnpm --filter "./apps/climatemapped-africa" build

#
# climatemapped-africa-runner: final deployable image
# ---------------------------------------

FROM base-runner as climatemapped-africa-runner

ARG NEXT_PUBLIC_IMAGE_DOMAINS \
NEXT_PUBLIC_IMAGE_SCALE_FACTOR \
NEXT_PUBLIC_OPENAFRICA_DOMAINS \
NEXT_PUBLIC_SOURCEAFRICA_DOMAINS

ENV NEXT_PUBLIC_IMAGE_DOMAINS=${NEXT_PUBLIC_IMAGE_DOMAINS} \
NEXT_PUBLIC_IMAGE_SCALE_FACTOR=${NEXT_PUBLIC_IMAGE_SCALE_FACTOR} \
NEXT_PUBLIC_OPENAFRICA_DOMAINS=${NEXT_PUBLIC_OPENAFRICA_DOMAINS} \
NEXT_PUBLIC_SOURCEAFRICA_DOMAINS=${NEXT_PUBLIC_SOURCEAFRICA_DOMAINS}

RUN set -ex \
# Create nextjs cache dir w/ correct permissions
&& mkdir -p ./apps/climatemapped-africa/.next \
&& chown nextjs:nodejs ./apps/climatemapped-africa/.next

# PNPM
# symlink some dependencies
COPY --from=climatemapped-africa-builder --chown=nextjs:nodejs /workspace/node_modules ./node_modules

# Next.js
# Public assets
COPY --from=climatemapped-africa-builder --chown=nextjs:nodejs /workspace/apps/climatemapped-africa/public ./apps/climatemapped-africa/public

# Automatically leverage output traces to reduce image size
# https://nextjs.org/docs/advanced-features/output-file-tracing
COPY --from=climatemapped-africa-builder --chown=nextjs:nodejs /workspace/apps/climatemapped-africa/.next/standalone ./apps/climatemapped-africa
COPY --from=climatemapped-africa-builder --chown=nextjs:nodejs /workspace/apps/climatemapped-africa/.next/static ./apps/climatemapped-africa/.next/static

USER nextjs

# server.js is created by next build from the standalone output
# https://nextjs.org/docs/pages/api-reference/next-config-js/output
CMD ["node", "apps/climatemapped-africa/server.js"]
92 changes: 0 additions & 92 deletions Dockerfile.hurumap

This file was deleted.

0 comments on commit 61eedab

Please sign in to comment.