mahesh1209 commited on
Commit
8a0049d
·
verified ·
1 Parent(s): 47f5117

Update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +38 -9
Dockerfile CHANGED
@@ -1,17 +1,46 @@
1
- # Use lightweight Python image
2
- FROM python:3.10-slim
3
 
4
  WORKDIR /app
5
 
6
  # Install dependencies
7
- COPY requirements.txt .
8
- RUN pip install --no-cache-dir -r requirements.txt
9
 
10
- # Copy app code
11
- COPY . .
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
12
 
13
- # Expose port
14
  EXPOSE 7860
15
 
16
- # Run Flask
17
- CMD ["python", "app.py"]
 
1
+ # Use slim Python image
2
+ FROM python:3.11-slim
3
 
4
  WORKDIR /app
5
 
6
  # Install dependencies
7
+ COPY backend/requirements.txt /app/backend/requirements.txt
8
+ RUN pip install --no-cache-dir -r /app/backend/requirements.txt
9
 
10
+ # Copy backend
11
+ COPY backend /app/backend
12
+
13
+ # Copy frontend to a static dir served by Flask (optional) or via simple file server
14
+ COPY frontend /app/frontend
15
+
16
+ # Add a tiny static server via Flask for simplicity:
17
+ # We'll modify backend/app.py at runtime to serve /frontend
18
+ # Instead, we can use a simple nginx, but keep it minimal:
19
+ RUN python - <<'PY'\n\
20
+ import os\n\
21
+ p = '/app/backend/app.py'\n\
22
+ s = open(p).read()\n\
23
+ addon = '''\n\
24
+ from flask import send_from_directory\n\
25
+ @app.route('/<path:path>')\n\
26
+ def static_proxy(path):\n\
27
+ return send_from_directory('/app/frontend', path)\n\
28
+ @app.route('/index.html')\n\
29
+ def index_html():\n\
30
+ return send_from_directory('/app/frontend', 'index.html')\n\
31
+ @app.route('/style.css')\n\
32
+ def style_css():\n\
33
+ return send_from_directory('/app/frontend', 'style.css')\n\
34
+ @app.route('/app.js')\n\
35
+ def app_js():\n\
36
+ return send_from_directory('/app/frontend', 'app.js')\n\
37
+ @app.route('/frontend')\n\
38
+ def frontend_root():\n\
39
+ return send_from_directory('/app/frontend', 'index.html')\n\
40
+ '''\n\
41
+ open(p, 'w').write(s + '\\n' + addon)\n\
42
+ PY
43
 
 
44
  EXPOSE 7860
45
 
46
+ CMD ["gunicorn", "-w", "1", "-b", "0.0.0.0:7860", "backend.app:app"]