diff --git a/.github/workflows/hurumap-deploy-dev.yml b/.github/workflows/climatemapped-africa-deploy-dev.yml similarity index 83% rename from .github/workflows/hurumap-deploy-dev.yml rename to .github/workflows/climatemapped-africa-deploy-dev.yml index 51845e0fc..e2fb731a2 100644 --- a/.github/workflows/hurumap-deploy-dev.yml +++ b/.github/workflows/climatemapped-africa-deploy-dev.yml @@ -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 }}" @@ -15,10 +15,10 @@ concurrency: env: DOKKU_REMOTE_BRANCH: "master" DOKKU_REMOTE_URL: "ssh://azureuser@ui-1.dev.codeforafrica.org" - 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: @@ -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 }}" diff --git a/Dockerfile b/Dockerfile index 1a8d29ffb..55c3d8830 100644 --- a/Dockerfile +++ b/Dockerfile @@ -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"] diff --git a/Dockerfile.hurumap b/Dockerfile.hurumap deleted file mode 100644 index 4dc43e4b6..000000000 --- a/Dockerfile.hurumap +++ /dev/null @@ -1,92 +0,0 @@ -FROM node:20.14-alpine as node-alpine - -# 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 -RUN apk update \ - && apk upgrade - -FROM node-alpine as base - -# 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 - -ARG PNPM_VERSION=9.1.4 - -RUN corepack enable && corepack prepare pnpm@${PNPM_VERSION} --activate - -WORKDIR /workspace - -COPY pnpm-lock.yaml . - -RUN pnpm fetch - - -FROM base as builder - -WORKDIR /workspace - -COPY *.yaml *.json ./ -COPY packages ./packages -COPY apps/hurumap ./apps/hurumap - -# Use virtual store: https://pnpm.io/cli/fetch#usage-scenario -RUN pnpm install --recursive --offline --frozen-lockfile - -ARG NEXT_TELEMETRY_DISABLED=1 \ - # Needed by Next.js at build time - NEXT_PUBLIC_APP_NAME=Hurumap \ - NEXT_PUBLIC_APP_URL=http://localhost:3000 \ - NEXT_PUBLIC_SENTRY_DSN="" \ - NEXT_PUBLIC_SEO_DISABLED="true" \ - NEXT_PUBLIC_IMAGE_DOMAINS="cms.dev.codeforafrica.org,hurumap-v2.s3.amazonaws.com" \ - NEXT_PUBLIC_IMAGE_SCALE_FACTOR=2 \ - NEXT_PUBLIC_OPENAFRICA_DOMAINS="open.africa,openafrica.net,africaopendata.org" \ - NEXT_PUBLIC_SOURCEAFRICA_DOMAINS="dc.sourceafrica.net" \ - NEXT_PUBLIC_GOOGLE_ANALYTICS="" \ - # Needed by Next.js and server.ts at build time - PORT=3000 \ - # Sentry config for source maps upload (needed at build time only) - SENTRY_AUTH_TOKEN="" \ - SENTRY_ENV="" \ - SENTRY_ORG="" \ - SENTRY_PROJECT="" \ - HURUMAP_API_URL - -RUN pnpm build --filter=hurumap - -FROM builder as runner - -# Remember to remove local cache from runner -RUN rm -rf /var/cache/apk/* - -ARG NEXT_TELEMETRY_DISABLED \ - NEXT_PUBLIC_APP_NAME \ - NEXT_PUBLIC_APP_URL \ - NEXT_PUBLIC_SENTRY_DSN \ - NEXT_PUBLIC_SEO_DISABLED \ - NEXT_PUBLIC_IMAGE_DOMAINS \ - NEXT_PUBLIC_IMAGE_SCALE_FACTOR \ - NEXT_PUBLIC_OPENAFRICA_DOMAINS \ - NEXT_PUBLIC_SOURCEAFRICA_DOMAINS \ - NEXT_PUBLIC_GOOGLE_ANALYTICS \ - PORT \ - SENTRY_ENV - -ENV NODE_ENV=production \ - NEXT_PUBLIC_APP_NAME=${NEXT_PUBLIC_APP_NAME} \ - NEXT_PUBLIC_APP_URL=${NEXT_PUBLIC_APP_URL} \ - NEXT_PUBLIC_SENTRY_DSN=${NEXT_PUBLIC_SENTRY_DSN} \ - NEXT_PUBLIC_SEO_DISABLED=${NEXT_PUBLIC_SEO_DISABLED} \ - 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} \ - NEXT_PUBLIC_GOOGLE_ANALYTICS=${NEXT_PUBLIC_GOOGLE_ANALYTICS} \ - PORT=${PORT} \ - SENTRY_ENV=${SENTRY_ENV} - -WORKDIR /workspace/apps/hurumap - -EXPOSE ${PORT} - -CMD ["pnpm", "start"]