-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDockerfile
40 lines (26 loc) · 926 Bytes
/
Dockerfile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
# Base image for building dependencies (multi-stage build)
FROM python:3.12-slim as builder
# Set working directory
WORKDIR /app
# Copy requirements
COPY requirements.txt requirements.txt
RUN apt-get update && apt-get install -y gcc
# Upgrade pip
RUN pip install --upgrade pip
RUN pip install gunicorn psycopg2-binary whitenoise
# Install dependencies with increased timeout
RUN pip install --default-timeout=100 --no-cache-dir -r requirements.txt
# Base image for the final application
FROM python:3.12-slim as final
# Set working directory
WORKDIR /app
# Copy project files
COPY . .
# Copy dependencies from builder stage
COPY --from=builder /usr/local/lib/python3.12/site-packages /usr/local/lib/python3.12/site-packages
# Set environment variables
ENV PYTHONDONTWRITEBYTECODE 1
ENV PYTHONUNBUFFERED 1
EXPOSE 8000
# Startup command for the application
CMD ["python", "manage.py", "runserver", "0.0.0.0:8000"]