deploy(Dockerfile): Ajusta o dockerfile para produção
This commit is contained in:
parent
205a20b3ce
commit
6bb4c10eb0
1 changed files with 6 additions and 11 deletions
17
Dockerfile
17
Dockerfile
|
|
@ -27,35 +27,30 @@ WORKDIR /app
|
||||||
# Copia dependências instaladas do estágio builder
|
# Copia dependências instaladas do estágio builder
|
||||||
COPY --from=builder /install /usr/local
|
COPY --from=builder /install /usr/local
|
||||||
|
|
||||||
# Copia o restante do código
|
# Copia o restante do código da aplicação
|
||||||
COPY . .
|
COPY . .
|
||||||
|
|
||||||
# Adiciona um usuário não-root para segurança
|
|
||||||
RUN addgroup --system app && adduser --system --ingroup app appuser
|
|
||||||
USER appuser
|
|
||||||
|
|
||||||
# Define timezone e ambiente
|
# Define timezone e ambiente
|
||||||
ENV TZ=America/Sao_Paulo \
|
ENV TZ=America/Sao_Paulo \
|
||||||
PYTHONUNBUFFERED=1 \
|
PYTHONUNBUFFERED=1 \
|
||||||
PYTHONDONTWRITEBYTECODE=1 \
|
PYTHONDONTWRITEBYTECODE=1 \
|
||||||
UVICORN_WORKERS=4 \
|
UVICORN_WORKERS=4 \
|
||||||
UVICORN_PORT=8000 \
|
UVICORN_PORT=8000 \
|
||||||
UVICORN_HOST=0.0.0.0
|
UVICORN_HOST=0.0.0.0 \
|
||||||
|
GUNICORN_CMD_ARGS="--log-level info --timeout 60 --graceful-timeout 30 --keep-alive 10"
|
||||||
|
|
||||||
# Expõe a porta de aplicação
|
# Expõe a porta padrão do app
|
||||||
EXPOSE 8000
|
EXPOSE 8000
|
||||||
|
|
||||||
# ==============================
|
# ==============================
|
||||||
# Comando de inicialização (Gunicorn + Uvicorn Workers)
|
# Comando de inicialização
|
||||||
|
# (Gunicorn + Uvicorn Workers)
|
||||||
# ==============================
|
# ==============================
|
||||||
CMD ["sh", "-c", "\
|
CMD ["sh", "-c", "\
|
||||||
gunicorn main:app \
|
gunicorn main:app \
|
||||||
--worker-class uvicorn.workers.UvicornWorker \
|
--worker-class uvicorn.workers.UvicornWorker \
|
||||||
--workers ${UVICORN_WORKERS:-4} \
|
--workers ${UVICORN_WORKERS:-4} \
|
||||||
--bind ${UVICORN_HOST:-0.0.0.0}:${UVICORN_PORT:-8000} \
|
--bind ${UVICORN_HOST:-0.0.0.0}:${UVICORN_PORT:-8000} \
|
||||||
--timeout 60 \
|
|
||||||
--keep-alive 10 \
|
|
||||||
--access-logfile '-' \
|
--access-logfile '-' \
|
||||||
--error-logfile '-' \
|
--error-logfile '-' \
|
||||||
--graceful-timeout 30 \
|
|
||||||
"]
|
"]
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue