更改目录
This commit is contained in:
42
Dockerfile/web/apex/aqex_web_Dockerfile
Normal file
42
Dockerfile/web/apex/aqex_web_Dockerfile
Normal file
@@ -0,0 +1,42 @@
|
||||
# ===============================
|
||||
# 1) 依赖安装 + 构建阶段
|
||||
# ===============================
|
||||
FROM registry.cn-hangzhou.aliyuncs.com/docker_mirror/node:20.15.0-alpine AS build
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
# 只拷贝 package.json,加快缓存命中
|
||||
COPY package.json ./
|
||||
|
||||
# 预先安装依赖(利用缓存)
|
||||
RUN pnpm install --registry=https://registry.npmmirror.com
|
||||
|
||||
# 拷贝全部代码
|
||||
COPY . .
|
||||
|
||||
# 要求 package.json 中的 script 形如:build:sit, build:test, build:prod
|
||||
RUN pnpm build
|
||||
|
||||
RUN mv /app/dist/main/index.html /app/dist/index.html
|
||||
|
||||
# ===============================
|
||||
# 2) 生产镜像阶段
|
||||
# ===============================
|
||||
FROM registry.cn-hangzhou.aliyuncs.com/docker_mirror/nginx:1.25-alpine AS runtime
|
||||
|
||||
# 清理默认 nginx 静态内容
|
||||
RUN rm -rf /usr/share/nginx/html/*
|
||||
|
||||
# 拷贝自定义 nginx 配置文件
|
||||
COPY nginx.conf /etc/nginx/nginx.conf
|
||||
|
||||
# 拷贝 build 结果
|
||||
COPY --from=build /app/dist /usr/share/nginx/html/
|
||||
|
||||
# 权限
|
||||
RUN chmod -R 755 /usr/share/nginx/html
|
||||
|
||||
EXPOSE 80
|
||||
|
||||
CMD ["nginx", "-g", "daemon off;"]
|
||||
|
||||
Reference in New Issue
Block a user