From 708fd36b8d714d96ac021cce99bb046dce0742c7 Mon Sep 17 00:00:00 2001 From: thenav56 Date: Mon, 8 Sep 2025 22:41:29 +0545 Subject: [PATCH 1/3] feat(docker): add new "builder" stage for mapswipe-deploy --- Dockerfile | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/Dockerfile b/Dockerfile index 238537d..a8a2c14 100644 --- a/Dockerfile +++ b/Dockerfile @@ -10,16 +10,21 @@ RUN apt-get update -y \ WORKDIR /code -# -------------------------- web-app-serve- Builder -------------------------------- - -FROM dev AS web-app-serve-build +# -------------------------- Builder --------------------------------------- -COPY ./package.json ./pnpm-lock.yaml /code/ +FROM dev AS builder -RUN pnpm install +RUN --mount=type=cache,id=pnpm,target=/pnpm/store \ + --mount=type=bind,source=package.json,target=package.json \ + --mount=type=bind,source=pnpm-lock.yaml,target=pnpm-lock.yaml \ + pnpm install --frozen-lockfile COPY . /code/ +# -------------------------- web-app-serve- Builder -------------------------------- + +FROM builder AS web-app-serve-build + # Build variables (Requires backend pulled) ENV APP_GRAPHQL_ENDPOINT=http://localhost:8000/graphql/ From 0680edf49d2870866097fb58abbd9c0246d6cbdc Mon Sep 17 00:00:00 2001 From: thenav56 Date: Mon, 8 Sep 2025 22:41:08 +0545 Subject: [PATCH 2/3] feat(config): allow commitHash with environment variable use git cli as fallback --- vite.config.ts | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/vite.config.ts b/vite.config.ts index 0b27289..b6d25d4 100644 --- a/vite.config.ts +++ b/vite.config.ts @@ -10,7 +10,22 @@ import { ValidateEnv as validateEnv } from '@julr/vite-plugin-validate-env'; import communityDashboardPackage from './package.json'; /* Get commit hash */ -const commitHash = execSync('git rev-parse --short HEAD').toString(); +function getCommitHash(): string { + if (process.env.APP_COMMIT_HASH) { + return process.env.APP_COMMIT_HASH; + } + + try { + return execSync('git rev-parse --short HEAD').toString().trim(); + } catch (error) { + throw new Error( + 'Unable to determine commit hash. You must either provide a commit hash using the APP_COMMIT_HASH environment variable,' + + ' or provide a valid Git repository (submodule doesn\'t work with docker).' + ); + } +} + +const commitHash = getCommitHash(); export default defineConfig(({ mode }) => { const isProd = mode === 'production'; From cd8ce8e69b7aee53f0f371805db972a824b779be Mon Sep 17 00:00:00 2001 From: thenav56 Date: Wed, 10 Sep 2025 19:10:22 +0545 Subject: [PATCH 3/3] chore: rename staging to stage for environment naming --- env.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/env.ts b/env.ts index 0189227..3852a8d 100644 --- a/env.ts +++ b/env.ts @@ -24,7 +24,7 @@ export default defineConfig({ APP_ENVIRONMENT: (key: string, value: string) => { // NOTE: APP_ENVIRONMENT_PLACEHOLDER is meant to be used with image builds // The value will be later replaced with the actual value - const regex = /^PROD|staging|testing|ci|alpha-\d+|ALPHA-\d+|DEV|APP_ENVIRONMENT_PLACEHOLDER$/; + const regex = /^PROD|stage|testing|ci|alpha-\d+|ALPHA-\d+|DEV|APP_ENVIRONMENT_PLACEHOLDER$/; const valid = !!value && (value.match(regex) !== null); if (!valid) { throw new Error(`Value for environment variable "${key}" must match regex "${regex}", instead received "${value}"`); @@ -32,7 +32,7 @@ export default defineConfig({ if (value === 'APP_ENVIRONMENT_PLACEHOLDER') { console.warn(`Using ${value} for app environment. Make sure to not use this for builds without nginx-serve`); } - return value as ('PROD' | 'staging' | 'testing' | 'ci' | `alpha-${number}` | 'DEV' | 'APP_ENVIRONMENT_PLACEHOLDER' | `ALPHA-${number}`); + return value as ('PROD' | 'stage' | 'testing' | 'ci' | `alpha-${number}` | 'DEV' | 'APP_ENVIRONMENT_PLACEHOLDER' | `ALPHA-${number}`); }, APP_GA_TRACKING_ID: Schema.string.optional(), APP_GRAPHQL_CODEGEN_ENDPOINT: Schema.string(),