ci: 添加前端构建缓存清除策略并更新阿里云配置

为前端服务添加构建时的缓存清除策略,通过引入CACHEBUST参数确保每次构建获取最新依赖
更新docker-compose.aliyun.yml添加pull_policy配置确保总是拉取最新镜像
This commit is contained in:
fanfpy 2025-07-21 14:40:08 +08:00
parent 72876620ad
commit b7f58971fe
3 changed files with 7 additions and 2 deletions

View File

@ -30,7 +30,11 @@ for service in "${SERVICES[@]}"; do
# 构建Docker镜像
echo "正在构建镜像: $IMAGE_NAME"
if [ "$service" = "frontend" ]; then
docker build --build-arg CACHEBUST=$(date +%s) -t $IMAGE_NAME $SERVICE_DIR
else
docker build -t $IMAGE_NAME $SERVICE_DIR
fi
if [ $? -ne 0 ]; then
echo "镜像构建失败"
exit 1

View File

@ -108,6 +108,7 @@ services:
frontend:
image: crpi-amr0dt5e5pywqwaf.cn-hangzhou.personal.cr.aliyuncs.com/testrrr/frontend:latest
pull_policy: always
container_name: ari-frontend
restart: always
depends_on:

View File

@ -3,7 +3,7 @@ WORKDIR /app
COPY package*.json ./
RUN npm install
COPY . .
RUN npm run build
RUN echo "Cachebust: $CACHEBUST" && npm run build
FROM nginx:stable-alpine as production-stage
COPY --from=build-stage /app/dist /usr/share/nginx/html