Xiao commited on
Commit
4214f3f
·
1 Parent(s): c9a7d52
Files changed (6) hide show
  1. .nginx/nginx.conf +22 -2
  2. Dockerfile +5 -3
  3. app.py +5 -2
  4. docker-compose.yaml +2 -1
  5. requirements.txt +0 -3
  6. run_hf.sh +1 -1
.nginx/nginx.conf CHANGED
@@ -3,6 +3,21 @@ events {
3
  }
4
 
5
  http {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
6
  server {
7
 
8
  listen 5000;
@@ -15,12 +30,17 @@ http {
15
  # try_files $uri /index.html =404;
16
  }
17
 
18
- location /api {
19
  # root /usr/share/nginx/html;
20
  # root /app/public;
21
  # index index.html index.htm;
22
- proxy_pass http://localhost:8000;
23
  # try_files $uri /index.html =404;
 
 
 
 
 
24
  }
25
 
26
  error_page 500 502 503 504 /50x.html;
 
3
  }
4
 
5
  http {
6
+ server {
7
+ listen 80 ;
8
+ location /api/ {
9
+ # root /usr/share/nginx/html;
10
+ # root /app/public;
11
+ # index index.html index.htm;
12
+ proxy_pass http://localhost:8000/;
13
+ # try_files $uri /index.html =404;
14
+ proxy_http_version 1.1;
15
+ proxy_set_header Upgrade $http_upgrade;
16
+ proxy_set_header Connection 'upgrade';
17
+ proxy_set_header Host $host;
18
+ proxy_cache_bypass $http_upgrade;
19
+ }
20
+ }
21
  server {
22
 
23
  listen 5000;
 
30
  # try_files $uri /index.html =404;
31
  }
32
 
33
+ location /api/ {
34
  # root /usr/share/nginx/html;
35
  # root /app/public;
36
  # index index.html index.htm;
37
+ proxy_pass http://localhost:8000/;
38
  # try_files $uri /index.html =404;
39
+ proxy_http_version 1.1;
40
+ proxy_set_header Upgrade $http_upgrade;
41
+ proxy_set_header Connection 'upgrade';
42
+ proxy_set_header Host $host;
43
+ proxy_cache_bypass $http_upgrade;
44
  }
45
 
46
  error_page 500 502 503 504 /50x.html;
Dockerfile CHANGED
@@ -70,7 +70,9 @@ RUN chown -R luminlab /var/cache/nginx \
70
 
71
  # COPY --chown=luminlab .nginx/nginx.conf /etc/nginx/conf.d/default.conf
72
  COPY --chown=luminlab .nginx/nginx.conf /etc/nginx/nginx.conf
 
73
 
 
74
 
75
  # # Set home to the user's home directory
76
  # ENV HOME=/home/luminlab \
@@ -93,12 +95,11 @@ FROM lean AS dev
93
  COPY package.json /app/package.json
94
  COPY package-lock.json /app/package-lock.json
95
 
96
- COPY . /app
97
 
98
  WORKDIR /app
99
- # COPY --chown=luminlab requirements.txt /app/requirements.txt
100
 
101
- RUN pip install --no-cache-dir -r requirements.txt
102
 
103
  # Same as npm install
104
  RUN npm ci
@@ -154,6 +155,7 @@ EXPOSE 3000
154
  EXPOSE 5000
155
  #flask
156
  EXPOSE 8000
 
157
 
158
 
159
  RUN chmod 777 /app/run_hf.sh
 
70
 
71
  # COPY --chown=luminlab .nginx/nginx.conf /etc/nginx/conf.d/default.conf
72
  COPY --chown=luminlab .nginx/nginx.conf /etc/nginx/nginx.conf
73
+ COPY --chown=luminlab requirements.txt /app/requirements.txt
74
 
75
+ RUN pip install --no-cache-dir -r /app/requirements.txt
76
 
77
  # # Set home to the user's home directory
78
  # ENV HOME=/home/luminlab \
 
95
  COPY package.json /app/package.json
96
  COPY package-lock.json /app/package-lock.json
97
 
98
+ COPY --chown=luminlab . /app
99
 
100
  WORKDIR /app
 
101
 
102
+ # RUN pip install flask
103
 
104
  # Same as npm install
105
  RUN npm ci
 
155
  EXPOSE 5000
156
  #flask
157
  EXPOSE 8000
158
+ EXPOSE 80
159
 
160
 
161
  RUN chmod 777 /app/run_hf.sh
app.py CHANGED
@@ -16,8 +16,11 @@
16
  # blocks.launch()
17
  from flask import Flask
18
  app = Flask(__name__)
19
- app.run(host='0.0.0.0', port=8000, debug=True)
20
 
21
  @app.route('/')
22
  def hello_world():
23
- return 'Hello, World!'
 
 
 
 
16
  # blocks.launch()
17
  from flask import Flask
18
  app = Flask(__name__)
19
+
20
 
21
  @app.route('/')
22
  def hello_world():
23
+ return 'Hello, World!'
24
+
25
+ if __name__ == '__main__':
26
+ app.run(host='0.0.0.0', port=8000, debug=True)
docker-compose.yaml CHANGED
@@ -12,7 +12,8 @@ services:
12
  ports:
13
  - "5000:5000"
14
  - "3000:3000"
15
- # - "8000:8000"
 
16
  volumes:
17
  - ./run_hf.sh:/app/run_hf.sh
18
  - .nginx/nginx.conf:/etc/nginx/nginx.conf
 
12
  ports:
13
  - "5000:5000"
14
  - "3000:3000"
15
+ - "8000:8000"
16
+ - "80:80"
17
  volumes:
18
  - ./run_hf.sh:/app/run_hf.sh
19
  - .nginx/nginx.conf:/etc/nginx/nginx.conf
requirements.txt CHANGED
@@ -1,4 +1 @@
1
- # gradio==3.23.0
2
- # uvicorn
3
- # fastapi
4
  flask
 
 
 
 
1
  flask
run_hf.sh CHANGED
@@ -5,7 +5,7 @@ nginx &
5
  # nginx -g "daemon off;"
6
  echo starting flask
7
  export FLASK_APP=/app/app.py
8
- python -m flask run &
9
  echo starting nmp
10
  npm start
11
  # npm run prod
 
5
  # nginx -g "daemon off;"
6
  echo starting flask
7
  export FLASK_APP=/app/app.py
8
+ python -m flask run --host=0.0.0.0 --port=8000 &
9
  echo starting nmp
10
  npm start
11
  # npm run prod