orztv commited on
Commit
09b474c
·
1 Parent(s): f5fdde0
Files changed (6) hide show
  1. .gitattributes +0 -35
  2. Dockerfile +10 -8
  3. services.json +14 -2
  4. start.sh +4 -15
  5. traefik/dynamic.yml +17 -18
  6. traefik/traefik.yml +19 -6
.gitattributes DELETED
@@ -1,35 +0,0 @@
1
- *.7z filter=lfs diff=lfs merge=lfs -text
2
- *.arrow filter=lfs diff=lfs merge=lfs -text
3
- *.bin filter=lfs diff=lfs merge=lfs -text
4
- *.bz2 filter=lfs diff=lfs merge=lfs -text
5
- *.ckpt filter=lfs diff=lfs merge=lfs -text
6
- *.ftz filter=lfs diff=lfs merge=lfs -text
7
- *.gz filter=lfs diff=lfs merge=lfs -text
8
- *.h5 filter=lfs diff=lfs merge=lfs -text
9
- *.joblib filter=lfs diff=lfs merge=lfs -text
10
- *.lfs.* filter=lfs diff=lfs merge=lfs -text
11
- *.mlmodel filter=lfs diff=lfs merge=lfs -text
12
- *.model filter=lfs diff=lfs merge=lfs -text
13
- *.msgpack filter=lfs diff=lfs merge=lfs -text
14
- *.npy filter=lfs diff=lfs merge=lfs -text
15
- *.npz filter=lfs diff=lfs merge=lfs -text
16
- *.onnx filter=lfs diff=lfs merge=lfs -text
17
- *.ot filter=lfs diff=lfs merge=lfs -text
18
- *.parquet filter=lfs diff=lfs merge=lfs -text
19
- *.pb filter=lfs diff=lfs merge=lfs -text
20
- *.pickle filter=lfs diff=lfs merge=lfs -text
21
- *.pkl filter=lfs diff=lfs merge=lfs -text
22
- *.pt filter=lfs diff=lfs merge=lfs -text
23
- *.pth filter=lfs diff=lfs merge=lfs -text
24
- *.rar filter=lfs diff=lfs merge=lfs -text
25
- *.safetensors filter=lfs diff=lfs merge=lfs -text
26
- saved_model/**/* filter=lfs diff=lfs merge=lfs -text
27
- *.tar.* filter=lfs diff=lfs merge=lfs -text
28
- *.tar filter=lfs diff=lfs merge=lfs -text
29
- *.tflite filter=lfs diff=lfs merge=lfs -text
30
- *.tgz filter=lfs diff=lfs merge=lfs -text
31
- *.wasm filter=lfs diff=lfs merge=lfs -text
32
- *.xz filter=lfs diff=lfs merge=lfs -text
33
- *.zip filter=lfs diff=lfs merge=lfs -text
34
- *.zst filter=lfs diff=lfs merge=lfs -text
35
- *tfevents* filter=lfs diff=lfs merge=lfs -text
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
Dockerfile CHANGED
@@ -9,11 +9,12 @@ ENV TRAEFIK_CONFIG_FILE=/home/pn/app/traefik/traefik.yml
9
  RUN wget -q https://github.com/traefik/traefik/releases/download/v${TRAEFIK_VERSION}/traefik_v${TRAEFIK_VERSION}_linux_amd64.tar.gz \
10
  && tar -xzf traefik_v${TRAEFIK_VERSION}_linux_amd64.tar.gz \
11
  && mv traefik /usr/local/bin/ \
12
- && rm traefik_v${TRAEFIK_VERSION}_linux_amd64.tar.gz
13
-
14
- # 安装 jq 用于解析 JSON,http-server gettext-base(包含 envsubst)
15
- RUN apt-get update && apt-get install -y jq gettext-base curl && \
16
- npm install -g serve
 
17
 
18
  # 切换到 pn 用户
19
  USER pn
@@ -22,7 +23,7 @@ USER pn
22
  WORKDIR /home/pn/app
23
 
24
  # 创建必要的目录
25
- RUN mkdir -p /home/pn/app/traefik /home/pn/app/python /home/pn/app/node /home/pn/app/waeb && \
26
  chown -R pn:pn /home/pn /home/pn/app
27
 
28
  # 复制配置文件和启动脚本
@@ -35,10 +36,11 @@ RUN chmod +x /home/pn/app/start.sh
35
  # 设置环境变量
36
  ENV TRAEFIK_PORT=7860 \
37
  PYTHON_PORT=8000 \
38
- NODE_PORT=8001
 
39
 
40
  # 暴露 Traefik 和后端服务端口
41
- EXPOSE $TRAEFIK_PORT $PYTHON_PORT $NODE_PORT
42
 
43
  # 启动容器时运行启动脚本
44
  CMD ["/home/pn/app/start.sh"]
 
9
  RUN wget -q https://github.com/traefik/traefik/releases/download/v${TRAEFIK_VERSION}/traefik_v${TRAEFIK_VERSION}_linux_amd64.tar.gz \
10
  && tar -xzf traefik_v${TRAEFIK_VERSION}_linux_amd64.tar.gz \
11
  && mv traefik /usr/local/bin/ \
12
+ && rm traefik_v${TRAEFIK_VERSION}_linux_amd64.tar.gz \
13
+ # 安装 jq 用于解析 JSON,http-server 和 gettext-base(包含 envsubst)
14
+ && apt-get update && apt-get install -y jq gettext-base curl \
15
+ && npm install -g serve \
16
+ # 安装 n8n
17
+ && npm install -g n8n
18
 
19
  # 切换到 pn 用户
20
  USER pn
 
23
  WORKDIR /home/pn/app
24
 
25
  # 创建必要的目录
26
+ RUN mkdir -p /home/pn/app/traefik /home/pn/app/python /home/pn/app/node /home/pn/app/root /home/pn/app/n8n && \
27
  chown -R pn:pn /home/pn /home/pn/app
28
 
29
  # 复制配置文件和启动脚本
 
36
  # 设置环境变量
37
  ENV TRAEFIK_PORT=7860 \
38
  PYTHON_PORT=8000 \
39
+ NODE_PORT=8001 \
40
+ N8N_PORT=5678
41
 
42
  # 暴露 Traefik 和后端服务端口
43
+ EXPOSE $TRAEFIK_PORT $PYTHON_PORT $NODE_PORT $N8N_PORT
44
 
45
  # 启动容器时运行启动脚本
46
  CMD ["/home/pn/app/start.sh"]
services.json CHANGED
@@ -1,7 +1,7 @@
1
  [
2
  {
3
  "name": "python-service",
4
- "command": "python -m http.server",
5
  "port": 8000,
6
  "path_prefix": "/python",
7
  "health_check_path": "/",
@@ -12,7 +12,7 @@
12
  },
13
  {
14
  "name": "node-service",
15
- "command": "npx serve -s --listen $port --single --cors",
16
  "port": 8001,
17
  "path_prefix": "/node",
18
  "health_check_path": "/",
@@ -20,5 +20,17 @@
20
  "NODE_ENV": "production"
21
  },
22
  "working_dir": "/home/pn/app/node"
 
 
 
 
 
 
 
 
 
 
 
 
23
  }
24
  ]
 
1
  [
2
  {
3
  "name": "python-service",
4
+ "command": "python -m http.server $PORT",
5
  "port": 8000,
6
  "path_prefix": "/python",
7
  "health_check_path": "/",
 
12
  },
13
  {
14
  "name": "node-service",
15
+ "command": "npx serve -s --listen $PORT --single --cors",
16
  "port": 8001,
17
  "path_prefix": "/node",
18
  "health_check_path": "/",
 
20
  "NODE_ENV": "production"
21
  },
22
  "working_dir": "/home/pn/app/node"
23
+ },
24
+ {
25
+ "name": "n8n-service",
26
+ "command": "n8n start --port $PORT",
27
+ "port": 5678,
28
+ "path_prefix": "/",
29
+ "health_check_path": "/healthz",
30
+ "env": {
31
+ "N8N_PORT": "5678",
32
+ "N8N_EDITOR_BASE_URL": "/"
33
+ },
34
+ "working_dir": "/home/pn/app/n8n"
35
  }
36
  ]
start.sh CHANGED
@@ -17,8 +17,6 @@ touch /home/pn/app/python/hi.txt
17
  echo "Hello, Python!" > /home/pn/app/python/hi.txt
18
  touch /home/pn/app/node/hi.txt
19
  echo "Hello, Node!" > /home/pn/app/node/hi.txt
20
- touch /home/pn/app/hi.txt
21
- echo "Hello, Waeb!" > /home/pn/app/hi.txt
22
 
23
  # 启动服务
24
  echo "$services" | while read -r service; do
@@ -37,7 +35,7 @@ echo "$services" | while read -r service; do
37
  log "ERROR: Directory $working_dir does not exist"
38
  exit 1
39
  fi
40
- (cd $working_dir && eval "port=$port $command") &
41
  done
42
 
43
  # 等待服务启动
@@ -65,20 +63,11 @@ echo "$services" | while read -r service; do
65
  port=$(echo $service | jq -r '.port')
66
  health_check_path=$(echo $service | jq -r '.health_check_path')
67
 
68
- # 跳过 waeb-service 的健康检查
69
- if [ "$name" != "waeb-service" ]; then
70
- if ! check_health $port "$name" "$health_check_path"; then
71
- log "ERROR: 健康检查失败,退出程序"
72
- exit 1
73
- fi
74
- else
75
- log "跳过 waeb-service 的健康检查"
76
  fi
77
  done
78
 
79
- # 启动根路径服务
80
- log "Starting root service on port 8080"
81
- (cd /home/pn/app/root && python -m http.server 8080) &
82
-
83
  # 启动 Traefik
84
  exec traefik --configFile=$TRAEFIK_CONFIG_FILE
 
17
  echo "Hello, Python!" > /home/pn/app/python/hi.txt
18
  touch /home/pn/app/node/hi.txt
19
  echo "Hello, Node!" > /home/pn/app/node/hi.txt
 
 
20
 
21
  # 启动服务
22
  echo "$services" | while read -r service; do
 
35
  log "ERROR: Directory $working_dir does not exist"
36
  exit 1
37
  fi
38
+ (cd $working_dir && eval "PORT=$port $command") &
39
  done
40
 
41
  # 等待服务启动
 
63
  port=$(echo $service | jq -r '.port')
64
  health_check_path=$(echo $service | jq -r '.health_check_path')
65
 
66
+ if ! check_health $port "$name" "$health_check_path"; then
67
+ log "ERROR: 健康检查失败,退出程序"
68
+ exit 1
 
 
 
 
 
69
  fi
70
  done
71
 
 
 
 
 
72
  # 启动 Traefik
73
  exec traefik --configFile=$TRAEFIK_CONFIG_FILE
traefik/dynamic.yml CHANGED
@@ -1,18 +1,17 @@
1
  http:
2
  routers:
3
- my-waeb-router:
4
- rule: "PathPrefix(`/waeb`)"
5
- service: noop@internal
6
- middlewares:
7
- - traefik-plugin-waeb
8
- entryPoints:
9
- - traefik
10
-
11
  root:
12
- rule: "PathPrefix(`/`) && !PathPrefix(`/python`) && !PathPrefix(`/node`) && !PathPrefix(`/waeb`)"
13
- service: root
14
  priority: 1
15
 
 
 
 
 
 
 
 
16
  python-service:
17
  rule: "PathPrefix(`/python`)"
18
  service: python-service
@@ -28,6 +27,11 @@ http:
28
  - node-service-stripprefix
29
 
30
  middlewares:
 
 
 
 
 
31
  python-service-stripprefix:
32
  stripPrefix:
33
  prefixes:
@@ -37,17 +41,12 @@ http:
37
  stripPrefix:
38
  prefixes:
39
  - "/node"
40
-
41
- traefik-plugin-waeb:
42
- plugin:
43
- traefik-plugin-waeb:
44
- root: "/home/pn/app/waeb"
45
-
46
  services:
47
- root:
48
  loadBalancer:
49
  servers:
50
- - url: "http://localhost:8080"
51
 
52
  python-service:
53
  loadBalancer:
 
1
  http:
2
  routers:
 
 
 
 
 
 
 
 
3
  root:
4
+ rule: "PathPrefix(`/`) && !PathPrefix(`/python`) && !PathPrefix(`/node`) && !PathPrefix(`/traefik`)"
5
+ service: n8n-service
6
  priority: 1
7
 
8
+ traefik-dashboard:
9
+ rule: "PathPrefix(`/traefik`)"
10
+ service: api@internal
11
+ priority: 2
12
+ middlewares:
13
+ - traefik-dashboard-stripprefix
14
+
15
  python-service:
16
  rule: "PathPrefix(`/python`)"
17
  service: python-service
 
27
  - node-service-stripprefix
28
 
29
  middlewares:
30
+ traefik-dashboard-stripprefix:
31
+ stripPrefix:
32
+ prefixes:
33
+ - "/traefik"
34
+
35
  python-service-stripprefix:
36
  stripPrefix:
37
  prefixes:
 
41
  stripPrefix:
42
  prefixes:
43
  - "/node"
44
+
 
 
 
 
 
45
  services:
46
+ n8n-service:
47
  loadBalancer:
48
  servers:
49
+ - url: "http://localhost:5678"
50
 
51
  python-service:
52
  loadBalancer:
traefik/traefik.yml CHANGED
@@ -8,8 +8,6 @@ log:
8
  entryPoints:
9
  web:
10
  address: ":7860"
11
- traefik:
12
- address: ":8080"
13
 
14
  providers:
15
  file:
@@ -20,9 +18,24 @@ api:
20
  insecure: true
21
  dashboard: true
22
 
23
- # 添加 Waeb 插件配置
 
 
 
 
 
24
  experimental:
25
  plugins:
26
- traefik-plugin-waeb:
27
- moduleName: "github.com/tomMoulard/traefik-plugin-waeb"
28
- version: "v1.0.1"
 
 
 
 
 
 
 
 
 
 
 
8
  entryPoints:
9
  web:
10
  address: ":7860"
 
 
11
 
12
  providers:
13
  file:
 
18
  insecure: true
19
  dashboard: true
20
 
21
+ serversTransport:
22
+ maxIdleConnsPerHost: 100
23
+
24
+ pilot:
25
+ dashboard: false
26
+
27
  experimental:
28
  plugins:
29
+ enabled: false
30
+
31
+ accessLog: {}
32
+
33
+ tracing: {}
34
+
35
+ metrics: {}
36
+
37
+ # 设置 Traefik 以 pn 用户权限运行
38
+ users:
39
+ - name: pn
40
+ uid: 1000
41
+ gid: 1000