memex-in commited on
Commit
85034ff
·
verified ·
1 Parent(s): 12857b9

Update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +17 -12
Dockerfile CHANGED
@@ -1,19 +1,24 @@
1
- # Stage 1: Build dependencies
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 image with unprivileged nginx
8
- FROM nginxinc/nginx-unprivileged:1.25-alpine
9
- WORKDIR /app
10
- COPY --from=builder /app /app
11
- COPY nginx.conf /etc/nginx/nginx.conf
12
 
13
- # Create writable temp directory for nginx
14
- RUN mkdir -p /tmp/nginx/client_temp \
15
- && chmod -R 777 /tmp/nginx
16
 
17
  EXPOSE 7860
18
 
19
- CMD ["sh", "-c", "python -m uvicorn main:app --host 0.0.0.0 --port 8000 & nginx -g 'daemon off;'"]
 
 
1
+ # Single-stage build: Python + Nginx combined
2
+ FROM python:3.10-slim
3
+
4
  WORKDIR /app
5
+
6
+ # Install Nginx from Debian repo
7
+ RUN apt-get update && \
8
+ apt-get install -y nginx && \
9
+ rm -rf /var/lib/apt/lists/*
10
+
11
+ # Copy app, requirements, and config
12
  COPY requirements.txt main.py nginx.conf ./
 
13
 
14
+ # Install Python dependencies
15
+ RUN pip install --no-cache-dir -r requirements.txt
 
 
 
16
 
17
+ # Create writable tmp dirs for nginx
18
+ RUN mkdir -p /tmp/nginx && \
19
+ chown -R www-data:www-data /tmp/nginx
20
 
21
  EXPOSE 7860
22
 
23
+ # Start Uvicorn and Nginx together
24
+ CMD ["sh", "-c", "python -m uvicorn main:app --host 127.0.0.1 --port 8000 & nginx -g 'daemon off;'"]