auto-deploy-demo/deploy/Dockerfile.single

41 lines
832 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.

# 单端口模式 - 容器内置Nginx
# 宿主机Nginx转发到容器容器内Nginx根据路径分发到不同项目
FROM node:18-alpine
# 安装Nginx
RUN apk add --no-cache nginx
WORKDIR /app
# 复制package文件并安装依赖
COPY package*.json ./
RUN npm install --production
# 复制后端代码
COPY server ./server
# 复制前端构建产物
COPY client/dist ./client/dist
# 创建必要的目录
RUN mkdir -p /app/data /app/projects /app/nginx/sites-enabled /run/nginx
# 复制Nginx配置模板
COPY server/templates ./server/templates
# 创建Nginx主配置
RUN echo 'events { worker_connections 1024; } \
http { \
include /app/nginx/sites-enabled/*.conf; \
}' > /etc/nginx/nginx.conf
# 暴露端口
EXPOSE 80
# 复制启动脚本
COPY deploy/start.sh /start.sh
RUN chmod +x /start.sh
CMD ["/start.sh"]