Spaces:
Running
Running
DeFactOfficial
commited on
Commit
•
b419751
1
Parent(s):
a7d24e0
Update Dockerfile
Browse files- Dockerfile +12 -86
Dockerfile
CHANGED
@@ -50,102 +50,28 @@ EXPOSE 7860
|
|
50 |
|
51 |
# Configure nginx
|
52 |
RUN rm -f /etc/nginx/sites-enabled/default
|
53 |
-
COPY
|
54 |
-
server {
|
55 |
-
listen 7860;
|
56 |
-
server_name localhost;
|
57 |
-
|
58 |
-
# Specific to HF Spaces: Allow larger headers for their proxy setup
|
59 |
-
large_client_header_buffers 4 32k;
|
60 |
-
|
61 |
-
proxy_connect_timeout 600;
|
62 |
-
proxy_send_timeout 600;
|
63 |
-
proxy_read_timeout 600;
|
64 |
-
send_timeout 600;
|
65 |
-
|
66 |
-
# Additional headers specific to running behind HF Spaces proxy
|
67 |
-
proxy_set_header Host $host;
|
68 |
-
proxy_set_header X-Real-IP $remote_addr;
|
69 |
-
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
70 |
-
proxy_set_header X-Forwarded-Proto $scheme;
|
71 |
-
proxy_set_header X-Forwarded-Host $host;
|
72 |
-
|
73 |
-
client_max_body_size 50M;
|
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;
|
81 |
-
proxy_buffer_size 128k;
|
82 |
-
proxy_buffers 4 256k;
|
83 |
-
proxy_busy_buffers_size 256k;
|
84 |
-
}
|
85 |
-
|
86 |
-
#location /API/tts/ {
|
87 |
-
# rewrite ^/API/tts/(.*) /$1 break;
|
88 |
-
# proxy_pass http://localhost:5555;
|
89 |
-
# proxy_http_version 1.1;
|
90 |
-
# proxy_set_header Upgrade $http_upgrade;
|
91 |
-
# proxy_set_header Connection "upgrade";
|
92 |
-
#}
|
93 |
-
|
94 |
-
# Required for HF Spaces health checks
|
95 |
-
location / {
|
96 |
-
return 200 'OK';
|
97 |
-
add_header Content-Type text/plain;
|
98 |
-
}
|
99 |
-
}
|
100 |
-
EOF
|
101 |
-
|
102 |
RUN ln -s /etc/nginx/sites-available/reverse-proxy.conf /etc/nginx/sites-enabled/
|
103 |
|
104 |
-
#
|
105 |
-
|
106 |
-
# so no
|
107 |
-
|
108 |
-
# COPY <<-'EOF' $HOME/code/start.sh
|
109 |
-
#!/bin/bash
|
110 |
-
|
111 |
-
# Print environment info for debugging
|
112 |
-
echo "Container Environment:"
|
113 |
-
echo "====================="
|
114 |
-
env | grep -i HF_ || true
|
115 |
-
echo "====================="
|
116 |
-
|
117 |
-
echo "Stopping old services..."
|
118 |
-
pm2 delete all
|
119 |
|
|
|
|
|
120 |
|
121 |
# Start all services in background with logging
|
122 |
#cd /code/service1 && ./run.sh > /var/log/service1.log 2>&1 &
|
123 |
#cd /code/service2 && ./run.sh > /var/log/service2.log 2>&1 &
|
124 |
#cd /code/service3 && ./run.sh > /var/log/service3.log 2>&1 &
|
125 |
|
|
|
|
|
|
|
126 |
# Wait for services to start
|
127 |
-
sleep 5
|
128 |
|
129 |
-
#
|
130 |
-
|
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 |
-
|
139 |
-
|
140 |
-
# start the imaging + tts api
|
141 |
-
echo "Starting the API"
|
142 |
-
#ENTRYPOINT ["nodejs", "./api.js"]
|
143 |
-
|
144 |
-
cd $HOME/code && pm2 start api.js
|
145 |
-
|
146 |
-
#make our shell script runnable
|
147 |
-
#RUN chmod +x $HOME/code/start.sh
|
148 |
-
|
149 |
-
# Start everything
|
150 |
-
#CMD ["$HOME/code/start.sh"]
|
151 |
-
#ENTRYPOINT ["nodejs", "./api.js"]
|
|
|
50 |
|
51 |
# Configure nginx
|
52 |
RUN rm -f /etc/nginx/sites-enabled/default
|
53 |
+
COPY $HOME/code/conf/nginx.conf /etc/nginx/sites-available/reverse-proxy.conf
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
54 |
RUN ln -s /etc/nginx/sites-available/reverse-proxy.conf /etc/nginx/sites-enabled/
|
55 |
|
56 |
+
# Stop all old instances of the api service
|
57 |
+
RUN pm2 delete all
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
58 |
|
59 |
+
# Start nginx in foreground
|
60 |
+
RUN nginx -g 'daemon off;'
|
61 |
|
62 |
# Start all services in background with logging
|
63 |
#cd /code/service1 && ./run.sh > /var/log/service1.log 2>&1 &
|
64 |
#cd /code/service2 && ./run.sh > /var/log/service2.log 2>&1 &
|
65 |
#cd /code/service3 && ./run.sh > /var/log/service3.log 2>&1 &
|
66 |
|
67 |
+
# Start the API
|
68 |
+
ENTRYPOINT ["pm2", "start", "./api.js"]
|
69 |
+
|
70 |
# Wait for services to start
|
71 |
+
RUN sleep 5
|
72 |
|
73 |
+
# Display the status of the service, make sure it started
|
74 |
+
RUN pm2 list
|
|
|
75 |
|
76 |
# Tail the logs in background
|
77 |
+
#tail -f /var/log/*.log &
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|