2025-10-22 15:07:43 +08:00
|
|
|
# ---- Build stage ----
|
2025-10-22 15:17:29 +08:00
|
|
|
FROM docker.1ms.run/node:20-slim AS build
|
2025-10-22 14:21:47 +08:00
|
|
|
|
|
|
|
|
WORKDIR /app
|
2025-10-22 15:07:43 +08:00
|
|
|
|
2025-10-22 14:21:47 +08:00
|
|
|
COPY package*.json ./
|
|
|
|
|
RUN npm ci
|
2025-10-22 15:01:56 +08:00
|
|
|
|
2025-10-22 15:07:43 +08:00
|
|
|
COPY dist/ ./dist
|
|
|
|
|
COPY public/ ./public
|
|
|
|
|
COPY server/ ./server
|
|
|
|
|
COPY src/ ./src
|
|
|
|
|
COPY index.html ./
|
|
|
|
|
|
|
|
|
|
# ---- Runtime stage ----
|
2025-10-22 15:17:29 +08:00
|
|
|
FROM docker.1ms.run/nginx:1.27-alpine
|
2025-10-22 15:01:56 +08:00
|
|
|
|
|
|
|
|
RUN apk add --no-cache nodejs npm
|
|
|
|
|
|
|
|
|
|
WORKDIR /app
|
2025-10-22 14:21:47 +08:00
|
|
|
|
2025-10-22 15:07:43 +08:00
|
|
|
# 拷贝 Node.js 后端
|
|
|
|
|
COPY --from=build /app/server /app/server
|
2025-10-22 14:21:47 +08:00
|
|
|
|
2025-10-22 15:07:43 +08:00
|
|
|
# 拷贝前端静态文件
|
|
|
|
|
COPY --from=build /app/dist /usr/share/nginx/html
|
|
|
|
|
COPY --from=build /app/public /usr/share/nginx/html/public
|
|
|
|
|
COPY --from=build /app/index.html /usr/share/nginx/html/
|
2025-10-22 14:21:47 +08:00
|
|
|
|
2025-10-22 15:07:43 +08:00
|
|
|
# Nginx 配置
|
2025-10-22 15:01:56 +08:00
|
|
|
COPY nginx.conf /etc/nginx/nginx.conf
|
2025-10-22 14:21:47 +08:00
|
|
|
|
2025-10-22 15:01:56 +08:00
|
|
|
# 启动脚本
|
|
|
|
|
COPY start.sh /start.sh
|
|
|
|
|
RUN chmod +x /start.sh
|
2025-10-22 14:21:47 +08:00
|
|
|
|
2025-10-22 15:01:56 +08:00
|
|
|
EXPOSE 80
|
2025-10-22 14:21:47 +08:00
|
|
|
|
2025-10-22 15:01:56 +08:00
|
|
|
CMD ["/start.sh"]
|