sanbo commited on
Commit
6215df1
·
1 Parent(s): d7994b2

update sth. at 2024-10-30 12:12:36

Browse files
Files changed (3) hide show
  1. Dockerfile +11 -7
  2. nginx.conf +2 -0
  3. start.sh +8 -0
Dockerfile CHANGED
@@ -6,16 +6,20 @@ RUN apk add --no-cache nginx socat
6
 
7
  # 创建 nginx 所需的目录并赋予权限
8
  RUN mkdir -p /var/lib/nginx/tmp/client_body /var/lib/nginx/logs && \
9
- chmod -R 777 /var/lib/nginx
10
-
11
- # 创建 nginx 配置目录和日志目录
12
- RUN mkdir -p /var/log/nginx /etc/nginx/conf.d
13
 
14
  # 拷贝 nginx 配置文件
15
  COPY nginx.conf /etc/nginx/nginx.conf
16
 
17
- # 暴露端口 7860
18
  EXPOSE 7860
19
 
20
- # 启动命令,增加日志输出
21
- CMD (socat TCP-LISTEN:7860,fork TCP:localhost:8080 & nginx && echo "nginx started" && /app/duck2api) || (echo "Service failed to start" && tail -f /var/log/nginx/error.log)
 
 
 
 
 
6
 
7
  # 创建 nginx 所需的目录并赋予权限
8
  RUN mkdir -p /var/lib/nginx/tmp/client_body /var/lib/nginx/logs && \
9
+ chmod -R 777 /var/lib/nginx && \
10
+ mkdir -p /var/log/nginx /etc/nginx/conf.d && \
11
+ touch /var/log/nginx/access.log /var/log/nginx/error.log && \
12
+ chmod 777 /var/log/nginx/access.log /var/log/nginx/error.log
13
 
14
  # 拷贝 nginx 配置文件
15
  COPY nginx.conf /etc/nginx/nginx.conf
16
 
17
+ # 暴露对外端口 7860
18
  EXPOSE 7860
19
 
20
+ # 创建启动脚本并赋予执行权限
21
+ COPY start.sh /start.sh
22
+ RUN chmod +x /start.sh
23
+
24
+ # 设置启动命令
25
+ CMD ["/start.sh"]
nginx.conf CHANGED
@@ -6,12 +6,14 @@ http {
6
  include /etc/nginx/mime.types;
7
  access_log /var/log/nginx/access.log;
8
  error_log /var/log/nginx/error.log;
 
9
 
10
  server {
11
  listen 7860;
12
  server_name localhost;
13
 
14
  location / {
 
15
  proxy_pass http://127.0.0.1:8080;
16
  proxy_http_version 1.1;
17
  proxy_set_header Upgrade $http_upgrade;
 
6
  include /etc/nginx/mime.types;
7
  access_log /var/log/nginx/access.log;
8
  error_log /var/log/nginx/error.log;
9
+ keepalive_timeout 65;
10
 
11
  server {
12
  listen 7860;
13
  server_name localhost;
14
 
15
  location / {
16
+ # 代理请求到内部服务端口 8080
17
  proxy_pass http://127.0.0.1:8080;
18
  proxy_http_version 1.1;
19
  proxy_set_header Upgrade $http_upgrade;
start.sh ADDED
@@ -0,0 +1,8 @@
 
 
 
 
 
 
 
 
 
1
+ #!/bin/sh
2
+
3
+ # 启动 nginx 和 duck2api 服务
4
+ echo "Starting nginx..."
5
+ nginx &
6
+ echo "Starting duck2api..."
7
+
8
+ /app/duck2api