gauthamnairy commited on
Commit
7470b0a
·
verified ·
1 Parent(s): 90f1b53

Update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +13 -32
Dockerfile CHANGED
@@ -1,49 +1,30 @@
1
- # --- Backend build stage ---
2
- FROM python:3.9-slim AS backend
3
-
4
- WORKDIR /app
5
-
6
- # Copy backend code and requirements
7
- COPY ./backend ./backend
8
- COPY ./distance.py ./distance.py
9
- COPY ./area.py ./area.py
10
- COPY ./coordinate_converter.py ./coordinate_converter.py
11
- COPY ./terrain.py ./terrain.py
12
- COPY requirements.txt .
13
-
14
- # Install Python dependencies
15
- RUN pip install --no-cache-dir -r requirements.txt
16
-
17
- # --- Frontend static stage ---
18
- FROM nginx:alpine AS frontend
19
 
20
  WORKDIR /app
21
- COPY ./frontend /app/frontend
22
- COPY nginx.conf /etc/nginx/conf.d/default.conf
23
 
24
- # --- Final stage ---
25
- FROM python:3.9-slim
26
 
27
- WORKDIR /app
 
28
 
29
- # Copy backend from backend stage
30
- COPY --from=backend /app /app
31
 
32
- # Copy frontend static files and nginx config from frontend stage
33
- COPY --from=frontend /app/frontend /app/frontend
34
- COPY --from=frontend /etc/nginx/conf.d/default.conf /etc/nginx/conf.d/default.conf
35
 
36
- # Install Python dependencies again (for runtime)
37
- RUN pip install --no-cache-dir fastapi uvicorn httpx pyproj python-multipart pydantic python-dotenv aiofiles
38
 
39
  # Install nginx
40
  RUN apt-get update && apt-get install -y nginx && rm -rf /var/lib/apt/lists/*
41
 
42
- # Copy nginx config (again, for safety)
43
  COPY nginx.conf /etc/nginx/conf.d/default.conf
44
 
45
  # Expose the port nginx will listen on
46
  EXPOSE 7860
47
 
48
- # Start both FastAPI backend and nginx
49
  CMD uvicorn backend.main:app --host 0.0.0.0 --port 8000 & nginx -g 'daemon off;'
 
1
+ FROM python:3.9-slim
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2
 
3
  WORKDIR /app
 
 
4
 
5
+ # Copy backend code
6
+ COPY backend /app/backend
7
 
8
+ # Copy backend utility modules (if any are outside /backend, add more COPY lines)
9
+ # (Not needed if all are in /backend)
10
 
11
+ # Copy frontend static files
12
+ COPY frontend /app/frontend
13
 
14
+ # Copy requirements
15
+ COPY backend/requirements.txt /app/requirements.txt
 
16
 
17
+ # Install dependencies
18
+ RUN pip install --no-cache-dir -r /app/requirements.txt
19
 
20
  # Install nginx
21
  RUN apt-get update && apt-get install -y nginx && rm -rf /var/lib/apt/lists/*
22
 
23
+ # Copy nginx config
24
  COPY nginx.conf /etc/nginx/conf.d/default.conf
25
 
26
  # Expose the port nginx will listen on
27
  EXPOSE 7860
28
 
29
+ # Start FastAPI backend and nginx
30
  CMD uvicorn backend.main:app --host 0.0.0.0 --port 8000 & nginx -g 'daemon off;'