solitudeLin commited on
Commit
0e4daa3
·
verified ·
1 Parent(s): 5e2bc6f

Create Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +44 -0
Dockerfile ADDED
@@ -0,0 +1,44 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # 使用官方镜像
2
+ FROM calciumion/new-api:latest
3
+
4
+ # 设置时区(必须)
5
+ ENV TZ=Asia/Shanghai
6
+
7
+ # 安装 nginx 用于端口转发
8
+ RUN apt-get update && \
9
+ apt-get install -y nginx && \
10
+ rm -rf /var/lib/apt/lists/*
11
+
12
+ # 创建 nginx 配置
13
+ RUN echo 'events { worker_connections 1024; } \
14
+ http { \
15
+ server { \
16
+ listen 7860; \
17
+ location / { \
18
+ proxy_pass http://127.0.0.1:3000; \
19
+ proxy_set_header Host $host; \
20
+ proxy_set_header X-Real-IP $remote_addr; \
21
+ proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; \
22
+ } \
23
+ } \
24
+ }' > /etc/nginx/nginx.conf
25
+
26
+ # 创建数据目录
27
+ RUN mkdir -p /data
28
+
29
+ # 创建启动脚本
30
+ RUN echo '#!/bin/bash \
31
+ # 启动 nginx(后台运行) \
32
+ nginx -g "daemon on;" & \
33
+ # 启动 NewAPI(前台运行) \
34
+ exec /app/docker-entrypoint.sh' > /start.sh && \
35
+ chmod +x /start.sh
36
+
37
+ # 暴露端口
38
+ EXPOSE 7860
39
+
40
+ # 设置数据卷(Spaces 会自动挂载)
41
+ VOLUME /data
42
+
43
+ # 启动命令
44
+ CMD ["/start.sh"]