newapi / Dockerfile
solitudeLin's picture
Update Dockerfile
d145753 verified
raw
history blame
1.06 kB
# 使用官方镜像
FROM calciumion/new-api:latest
# 设置时区(必须)
ENV TZ=Asia/Shanghai
# 使用 Alpine 包管理器安装 nginx
RUN apk add --no-cache nginx
# 创建 nginx 配置
RUN echo 'events { worker_connections 1024; } \
http { \
server { \
listen 7860; \
location / { \
proxy_pass http://127.0.0.1:3000; \
proxy_set_header Host $host; \
proxy_set_header X-Real-IP $remote_addr; \
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; \
} \
} \
}' > /etc/nginx/nginx.conf
# 创建数据目录
RUN mkdir -p /data
# 创建启动脚本
RUN echo '#!/bin/sh \
# 启动 nginx(后台运行) \
nginx & \
# 启动 NewAPI(前台运行) \
exec /app/docker-entrypoint.sh' > /start.sh && \
chmod +x /start.sh
# 暴露端口
EXPOSE 7860
# 设置数据卷(Spaces 会自动挂载)
VOLUME /data
# 启动命令
CMD ["/start.sh"]