-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
66 lines (49 loc) · 1.63 KB
/
Dockerfile
File metadata and controls
66 lines (49 loc) · 1.63 KB
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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
#########################################
# STAGE 1 — BUILD (instala dependências)
#########################################
FROM python:3.11-slim AS builder
ENV PYTHONDONTWRITEBYTECODE=1
ENV PYTHONUNBUFFERED=1
# Instalar dependências do sistema
RUN apt-get update && apt-get install -y --no-install-recommends \
build-essential \
libpq-dev \
&& rm -rf /var/lib/apt/lists/*
WORKDIR /app
# Copia apenas requirements para cache eficiente
COPY requirements ./requirements
# Instala dependências em uma pasta isolada
RUN pip install --upgrade pip && \
pip install --prefix=/install -r requirements/production.txt
#########################################
# STAGE 2 — FINAL IMAGE (produção)
#########################################
FROM python:3.11-slim AS final
ENV PYTHONDONTWRITEBYTECODE=1
ENV PYTHONUNBUFFERED=1
# Instalar dependências essenciais para Postgres
RUN apt-get update && apt-get install -y --no-install-recommends \
libpq5 \
netcat-openbsd \
&& rm -rf /var/lib/apt/lists/*
WORKDIR /app
# Copia dependências já instaladas
COPY --from=builder /install /usr/local
# Copia o projeto inteiro
COPY . .
# Criar pastas obrigatórias de produção
RUN mkdir -p /app/staticfiles
# ENTRYPOINT
COPY entrypoint.sh /entrypoint.sh
RUN chmod +x /entrypoint.sh
ENTRYPOINT ["/entrypoint.sh"]
# Expor porta da aplicação
EXPOSE 8000
#########################################
# Comando final — Gunicorn em modo produção
#########################################
CMD ["gunicorn", "config.wsgi:application", \
"--bind", "0.0.0.0:8000", \
"--workers", "4", \
"--threads", "2", \
"--timeout", "120"]