DeFactOfficial commited on
Commit
8efa104
·
verified ·
1 Parent(s): fd0ee34

Update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +17 -7
Dockerfile CHANGED
@@ -27,6 +27,9 @@ RUN curl -L https://raw.githubusercontent.com/tj/n/master/bin/n -o n \
27
  && rm n \
28
  && npm install -g npm@latest
29
 
 
 
 
30
  # Create working directory that matches HF Spaces expectations
31
  WORKDIR $HOME/code
32
 
@@ -71,7 +74,7 @@ server {
71
 
72
  # the node.js api runs on localhost:6666
73
  # here we tell nginx that requests to /API should forward there
74
- location /API/ {
75
  #rewrite ^/API/images/(.*) /$1 break;
76
  proxy_pass http://localhost:6666;
77
  proxy_buffering on;
@@ -108,7 +111,12 @@ echo "====================="
108
  env | grep -i HF_ || true
109
  echo "====================="
110
 
111
- #cd $HOME/code && node api.js
 
 
 
 
 
112
 
113
  # Start all services in background with logging
114
  #cd /code/service1 && ./run.sh > /var/log/service1.log 2>&1 &
@@ -120,17 +128,19 @@ sleep 5
120
 
121
  # Check service status
122
  echo "Running services:"
123
- netstat -tulpn
124
 
125
  # Tail the logs in background
126
- tail -f /var/log/*.log &
127
 
128
  # Start nginx in foreground
129
  nginx -g 'daemon off;'
130
  EOF
131
 
132
- #RUN chmod +x $/code/start.sh
 
 
133
 
134
  # Start everything
135
- #CMD ["/code/start.sh"]
136
- ENTRYPOINT ["nodejs", "./api.js"]
 
27
  && rm n \
28
  && npm install -g npm@latest
29
 
30
+ # pm2 is awesome... lets you run node.js scripts as services with zero configuration
31
+ RUN npm install pm2 -g
32
+
33
  # Create working directory that matches HF Spaces expectations
34
  WORKDIR $HOME/code
35
 
 
74
 
75
  # the node.js api runs on localhost:6666
76
  # here we tell nginx that requests to /API should forward there
77
+ location /api/ {
78
  #rewrite ^/API/images/(.*) /$1 break;
79
  proxy_pass http://localhost:6666;
80
  proxy_buffering on;
 
111
  env | grep -i HF_ || true
112
  echo "====================="
113
 
114
+ echo "Stopping old services..."
115
+ pm2 delete all
116
+
117
+ # start the imaging + tts api
118
+ echo "Starting the API"
119
+ cd $HOME/code && pm2 start api.js
120
 
121
  # Start all services in background with logging
122
  #cd /code/service1 && ./run.sh > /var/log/service1.log 2>&1 &
 
128
 
129
  # Check service status
130
  echo "Running services:"
131
+ pm2 list
132
 
133
  # Tail the logs in background
134
+ #tail -f /var/log/*.log &
135
 
136
  # Start nginx in foreground
137
  nginx -g 'daemon off;'
138
  EOF
139
 
140
+
141
+ #make our shell script runnable
142
+ RUN chmod +x $HOME/code/start.sh
143
 
144
  # Start everything
145
+ CMD ["$HOME/code/start.sh"]
146
+ #ENTRYPOINT ["nodejs", "./api.js"]