Files
stock-scanner/frontend/Dockerfile
2025-03-07 04:08:11 +08:00

39 lines
827 B
Docker
Raw 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 build-stage
# 设置工作目录
WORKDIR /app
# 安装 yarn
RUN apk add --no-cache yarn
# 复制 package.json 和 yarn.lock如果有
COPY package*.json yarn*.lock ./
# 安装依赖
RUN yarn install --frozen-lockfile
# 复制项目文件
COPY . .
# 构建应用
RUN yarn build
# 生产阶段
FROM nginx:stable-alpine as production-stage
# 复制自定义nginx配置如需要
COPY nginx.conf /etc/nginx/conf.d/default.conf
# 从构建阶段复制构建结果到nginx服务目录
COPY --from=build-stage /app/dist /usr/share/nginx/html
# 暴露80端口
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;"]