raazkumar commited on
Commit
42adb22
·
verified ·
1 Parent(s): 25c5a33

Upload production/Dockerfile.prod

Browse files
Files changed (1) hide show
  1. production/Dockerfile.prod +24 -0
production/Dockerfile.prod ADDED
@@ -0,0 +1,24 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ FROM python:3.11-slim AS builder
2
+ RUN apt-get update && apt-get install -y --no-install-recommends \
3
+ gcc libpq-dev && rm -rf /var/lib/apt/lists/*
4
+ RUN python -m venv /opt/venv
5
+ ENV PATH="/opt/venv/bin:$PATH"
6
+ COPY requirements.prod.txt .
7
+ RUN pip install --no-cache-dir --upgrade pip && \
8
+ pip install --no-cache-dir -r requirements.prod.txt
9
+
10
+ FROM python:3.11-slim AS production
11
+ RUN apt-get update && apt-get install -y --no-install-recommends \
12
+ libpq5 curl && rm -rf /var/lib/apt/lists/*
13
+ COPY --from=builder /opt/venv /opt/venv
14
+ ENV PATH="/opt/venv/bin:$PATH"
15
+ RUN useradd --create-home --shell /bin/bash appuser
16
+ WORKDIR /app
17
+ COPY --chown=appuser:appuser production_server.py .
18
+ COPY --chown=appuser:appuser worker.py .
19
+ RUN chown -R appuser:appuser /app
20
+ USER appuser
21
+ EXPOSE 8000
22
+ HEALTHCHECK --interval=30s --timeout=10s --start-period=40s --retries=3 \
23
+ CMD curl -f http://localhost:8000/health || exit 1
24
+ CMD ["python", "-m", "production_server"]