memex-in commited on
Commit
34a4d1e
·
verified ·
1 Parent(s): f9050af

Update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +12 -10
Dockerfile CHANGED
@@ -1,16 +1,18 @@
1
- FROM python:3.10-slim
2
-
3
- # Install dependencies
4
- RUN apt-get update && apt-get install -y nginx
5
  WORKDIR /app
6
-
7
  COPY requirements.txt main.py nginx.conf ./
8
- RUN pip install -r requirements.txt
 
 
 
 
 
9
 
10
- # Remove default Nginx site, add ours
11
- RUN rm /etc/nginx/sites-enabled/default
12
- COPY nginx.conf /etc/nginx/sites-enabled/
13
 
14
  EXPOSE 7860
15
 
16
- CMD ["sh", "-c", "service nginx start && uvicorn main:app --host 0.0.0.0 --port 8000"]
 
1
+ # Stage 1: build dependencies and code
2
+ FROM python:3.10-slim AS builder
 
 
3
  WORKDIR /app
 
4
  COPY requirements.txt main.py nginx.conf ./
5
+ RUN pip install --no-cache-dir -r requirements.txt
6
+
7
+ # Stage 2: runtime with unprivileged nginx
8
+ FROM nginxinc/nginx-unprivileged:1.25-alpine
9
+ COPY --from=builder /app /app
10
+ COPY nginx.conf /etc/nginx/nginx.conf
11
 
12
+ # Prepare Nginx temp dirs
13
+ RUN mkdir -p /tmp/nginx/client_temp \
14
+ && chown -R nginx:nginx /tmp/nginx
15
 
16
  EXPOSE 7860
17
 
18
+ CMD ["sh", "-c", "uvicorn main:app --host 0.0.0.0 --port 8000 & nginx -g 'daemon off;'"]