Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 10 additions & 5 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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/
Expand Down
4 changes: 2 additions & 2 deletions env.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,15 @@ 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}"`);
}
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(),
Expand Down
17 changes: 16 additions & 1 deletion vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down