ci(dockerfile): fix missing commit hash (#2134)

Signed-off-by: GitHub <noreply@github.com>
This commit is contained in:
Fernando Fernández 2023-11-06 23:59:09 +01:00 committed by GitHub
parent db9542da53
commit b0a6250dc1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 3 deletions

View File

@ -20,13 +20,16 @@ import { browserslistToTargets } from 'lightningcss';
import virtualModules from './scripts/virtual-modules';
import { localeFilesFolder, srcRoot } from './scripts/paths';
const is_stable = !Number(process.env.IS_STABLE);
const commit_hash = is_stable && process.env.COMMIT_HASH;
export default defineConfig(({ mode }): UserConfig => {
const config: UserConfig = {
appType: 'spa',
base: './',
cacheDir: '../node_modules/.cache/vite',
define: {
__COMMIT_HASH__: JSON.stringify(process.env.COMMIT_HASH || '')
...(commit_hash && { __COMMIT_HASH__: JSON.stringify(commit_hash)})
},
plugins: [
virtual(virtualModules),

View File

@ -1,6 +1,7 @@
## This dockerfile builds the client entirely in a Docker context
FROM node:20-slim AS build
# slim image can't be used since we need git to fetch the commit hash
FROM node:20 AS build
# Set build arguments
ARG DEFAULT_SERVERS
@ -21,7 +22,7 @@ WORKDIR /app/frontend
RUN npm ci --no-audit --ignore-scripts
# Build client
RUN if [ $"IS_STABLE" = "0" ] ; then export COMMIT_HASH=$(git rev-parse HEAD) ; fi && npm run build
RUN COMMIT_HASH=$(git rev-parse HEAD) npm run build
# Deploy built distribution to nginx
FROM nginx:stable-alpine-slim