Files
aigc-frontend/Dockerfile copy
2026-04-21 11:28:52 +08:00

33 lines
851 B
Plaintext
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# 构建阶段
FROM node:18-alpine AS builder
WORKDIR /app
# 先复制包管理文件,利用缓存层
COPY package.json yarn.lock ./
RUN yarn install --frozen-lockfile
# 复制源代码并构建
COPY . .
RUN yarn build:prod
# 提取 API 地址供运行阶段使用
RUN grep '^VITE_BASE_API=' .env.production | sed 's/^VITE_BASE_API=[ \t]*//; s/[ \t]*$//; s/^"//; s/"$//' | tr -d '\r' > /app/.api_target
# 运行阶段nginx 服务静态文件
FROM nginx:stable-alpine
# 复制构建产物到 nginx 默认目录
COPY --from=builder /app/dist /usr/share/nginx/html
# 复制 API 目标地址文件和配置文件
COPY --from=builder /app/.api_target /etc/nginx/.api_target
COPY nginx.conf /etc/nginx/conf.d/default.conf
COPY entrypoint.sh /entrypoint.sh
RUN chmod +x /entrypoint.sh
# 暴露 80 端口
EXPOSE 80
ENTRYPOINT ["/entrypoint.sh"]