-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDockerfile
33 lines (26 loc) · 911 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
FROM python:3.13-slim
# Set environment variables
ENV PYTHONDONTWRITEBYTECODE=1
ENV PYTHONUNBUFFERED=1
# Make the port available at runtime via environment variable
ENV PORT=8080
WORKDIR /app
RUN useradd -ms /bin/bash appuser
# Install dependencies
COPY ./src/requirements.txt /app/requirements.txt
RUN pip install --no-cache-dir --upgrade -r /app/requirements.txt && rm -rf /root/.cache
# Copy application source code
COPY ./src /app
# Switch to non-root user
USER appuser
# Expose port and add health check
EXPOSE 8080
HEALTHCHECK --interval=30s --timeout=5s --start-period=10s --retries=3 CMD curl -f http://localhost:${PORT}/health || exit 1
ENTRYPOINT ["gunicorn"]
# Start Gunicorn with UvicornWorker
CMD ["--workers", "4", \
"--worker-class", "uvicorn.workers.UvicornWorker", \
"--bind", "0.0.0.0:8080", \
"--access-logfile", "-", \
"--error-logfile", "-", \
"server:app"]