build: 清理未使用变量优化构建
This commit is contained in:
@@ -4,20 +4,17 @@ FROM node:18-alpine as build-stage
|
||||
# 设置工作目录
|
||||
WORKDIR /app
|
||||
|
||||
# 安装 yarn
|
||||
RUN apk add --no-cache yarn
|
||||
|
||||
# 复制 package.json 和 yarn.lock(如果有)
|
||||
COPY package*.json yarn*.lock ./
|
||||
# 复制 package.json 和 package-lock.json(如果有)
|
||||
COPY package*.json ./
|
||||
|
||||
# 安装依赖
|
||||
RUN yarn install --frozen-lockfile
|
||||
RUN npm ci
|
||||
|
||||
# 复制项目文件
|
||||
COPY . .
|
||||
|
||||
# 构建应用
|
||||
RUN yarn build
|
||||
RUN npm run build
|
||||
|
||||
# 生产阶段
|
||||
FROM nginx:stable-alpine as production-stage
|
||||
@@ -35,5 +32,5 @@ EXPOSE 80
|
||||
HEALTHCHECK --interval=30s --timeout=10s --start-period=5s --retries=3 \
|
||||
CMD wget --quiet --tries=1 --spider http://localhost:80 || exit 1
|
||||
|
||||
# 启动nginx
|
||||
CMD ["nginx", "-g", "daemon off;"]
|
||||
# 设定Nginx是否以守护进程的方式启动
|
||||
CMD ["nginx", "-g", "daemon off;"]
|
||||
|
||||
Reference in New Issue
Block a user