Time_Effectiveness/Dockerfile
2025-10-22 15:08:31 +08:00

40 lines
704 B
Docker

# ---- Build stage ----
FROM node:20-slim AS build
WORKDIR /app
COPY package*.json ./
RUN npm ci
COPY dist/ ./dist
COPY public/ ./public
COPY server/ ./server
COPY src/ ./src
COPY index.html ./
# ---- Runtime stage ----
FROM nginx:1.27-alpine
RUN apk add --no-cache nodejs npm
WORKDIR /app
# 拷贝 Node.js 后端
COPY --from=build /app/server /app/server
# 拷贝前端静态文件
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/
# Nginx 配置
COPY nginx.conf /etc/nginx/nginx.conf
# 启动脚本
COPY start.sh /start.sh
RUN chmod +x /start.sh
EXPOSE 80
CMD ["/start.sh"]