orztv commited on
Commit
386efc8
·
1 Parent(s): c36ae83
Files changed (3) hide show
  1. Dockerfile +3 -2
  2. docker/app.js +12 -0
  3. docker/startup.sh +2 -8
Dockerfile CHANGED
@@ -21,8 +21,9 @@ RUN adduser -D -u 1000 nocodb && \
21
  chown -R nocodb:nocodb /etc/redis.conf /var/log/redis /var/run/redis /usr/app/data /var/lib/redis && \
22
  apk add --update --no-cache dasel dumb-init nodejs
23
 
24
- # 复制启动脚本并设置权限
25
  COPY docker/startup.sh /usr/src/appEntry/startup.sh
 
26
  RUN chmod +x /usr/src/appEntry/startup.sh
27
 
28
  # 切换到 nocodb 用户
@@ -43,7 +44,7 @@ ENV LITESTREAM_S3_SKIP_VERIFY=false \
43
  NC_DB="pg://localhost:5432?u=nocodb&p=nocodb_password&d=nocodb" \
44
  NC_REDIS_URL="redis://:redis_password@localhost:6379/4"
45
 
46
- EXPOSE 8080 5432 6379
47
  ENTRYPOINT ["/usr/bin/dumb-init", "--"]
48
 
49
  # 运行启动脚本
 
21
  chown -R nocodb:nocodb /etc/redis.conf /var/log/redis /var/run/redis /usr/app/data /var/lib/redis && \
22
  apk add --update --no-cache dasel dumb-init nodejs
23
 
24
+ # 复制启动脚本和 Node.js 示例程序并设置权限
25
  COPY docker/startup.sh /usr/src/appEntry/startup.sh
26
+ COPY docker/app.js /usr/src/app/docker/app.js
27
  RUN chmod +x /usr/src/appEntry/startup.sh
28
 
29
  # 切换到 nocodb 用户
 
44
  NC_DB="pg://localhost:5432?u=nocodb&p=nocodb_password&d=nocodb" \
45
  NC_REDIS_URL="redis://:redis_password@localhost:6379/4"
46
 
47
+ EXPOSE 8080 5432 6379 7860
48
  ENTRYPOINT ["/usr/bin/dumb-init", "--"]
49
 
50
  # 运行启动脚本
docker/app.js ADDED
@@ -0,0 +1,12 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ const http = require('http');
2
+
3
+ const server = http.createServer((req, res) => {
4
+ res.statusCode = 200;
5
+ res.setHeader('Content-Type', 'text/plain');
6
+ res.end('你好,世界!\n');
7
+ });
8
+
9
+ const port = 7860;
10
+ server.listen(port, () => {
11
+ console.log(`服务器运行在 http://localhost:${port}/`);
12
+ });
docker/startup.sh CHANGED
@@ -53,14 +53,8 @@ if ! redis-cli -p 6379 -a redis_password ping; then
53
  exit 1
54
  fi
55
 
56
- log "Nginx 配置文件内容:"
57
- if [ -f /etc/nginx/nginx.conf ]; then
58
- cat /etc/nginx/nginx.conf
59
- elif [ -f /usr/local/nginx/conf/nginx.conf ]; then
60
- cat /usr/local/nginx/conf/nginx.conf
61
- else
62
- log "未找到 Nginx 配置文件"
63
- fi
64
 
65
  log "启动主程序..."
66
  exec /usr/src/appEntry/start.sh
 
53
  exit 1
54
  fi
55
 
56
+ log "启动 Node.js 示例程序..."
57
+ node /usr/src/app/docker/app.js &
 
 
 
 
 
 
58
 
59
  log "启动主程序..."
60
  exec /usr/src/appEntry/start.sh