ci: 添加前端构建缓存清除策略并更新阿里云配置
为前端服务添加构建时的缓存清除策略,通过引入CACHEBUST参数确保每次构建获取最新依赖 更新docker-compose.aliyun.yml添加pull_policy配置确保总是拉取最新镜像
This commit is contained in:
parent
72876620ad
commit
b7f58971fe
@ -30,7 +30,11 @@ for service in "${SERVICES[@]}"; do
|
|||||||
|
|
||||||
# 构建Docker镜像
|
# 构建Docker镜像
|
||||||
echo "正在构建镜像: $IMAGE_NAME"
|
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
|
docker build -t $IMAGE_NAME $SERVICE_DIR
|
||||||
|
fi
|
||||||
if [ $? -ne 0 ]; then
|
if [ $? -ne 0 ]; then
|
||||||
echo "镜像构建失败"
|
echo "镜像构建失败"
|
||||||
exit 1
|
exit 1
|
||||||
|
|||||||
@ -108,6 +108,7 @@ services:
|
|||||||
|
|
||||||
frontend:
|
frontend:
|
||||||
image: crpi-amr0dt5e5pywqwaf.cn-hangzhou.personal.cr.aliyuncs.com/testrrr/frontend:latest
|
image: crpi-amr0dt5e5pywqwaf.cn-hangzhou.personal.cr.aliyuncs.com/testrrr/frontend:latest
|
||||||
|
pull_policy: always
|
||||||
container_name: ari-frontend
|
container_name: ari-frontend
|
||||||
restart: always
|
restart: always
|
||||||
depends_on:
|
depends_on:
|
||||||
|
|||||||
@ -3,7 +3,7 @@ WORKDIR /app
|
|||||||
COPY package*.json ./
|
COPY package*.json ./
|
||||||
RUN npm install
|
RUN npm install
|
||||||
COPY . .
|
COPY . .
|
||||||
RUN npm run build
|
RUN echo "Cachebust: $CACHEBUST" && npm run build
|
||||||
|
|
||||||
FROM nginx:stable-alpine as production-stage
|
FROM nginx:stable-alpine as production-stage
|
||||||
COPY --from=build-stage /app/dist /usr/share/nginx/html
|
COPY --from=build-stage /app/dist /usr/share/nginx/html
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user