diff --git a/front/Dockerfile b/front/Dockerfile index 0acc58c..f6ac464 100644 --- a/front/Dockerfile +++ b/front/Dockerfile @@ -1,7 +1,12 @@ FROM 172.31.127.251:8083/library/node:20.19.0-alpine as builder ARG ENV=prod +# 1. 定义构建参数 +ARG COMMIT_ID=unknown +# 2. 将参数设置为环境变量,这样在容器运行时也能读取到 +ENV GIT_COMMIT_ID=${COMMIT_ID} WORKDIR /usr/src/app COPY . . + RUN set -eux; \ sed -i 's/dl-cdn.alpinelinux.org/mirrors.aliyun.com/g' /etc/apk/repositories; \ apk update && apk upgrade; \ @@ -9,6 +14,7 @@ RUN set -eux; \ apk add pnpm; \ pnpm config set registry https://registry.npmmirror.com; \ pnpm install; \ + echo "Building revision: ${GIT_COMMIT_ID}"; \ pnpm build:$ENV; FROM 172.31.127.251:8083/library/fileserver:1.0.0