-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDockerfile
30 lines (22 loc) · 878 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
# Use a specific, slim Python image
FROM python:3.11.4-slim
# Set environment variables for optimal performance
ENV PYTHONDONTWRITEBYTECODE=1
ENV PYTHONUNBUFFERED=1
# Create a non-root user
RUN adduser --disabled-password --gecos "" appuser
# Install system dependencies and clean up afterward
RUN apt-get update && apt-get install -y --no-install-recommends \
libgomp1 \
&& rm -rf /var/lib/apt/lists/*
COPY requirements.txt .
RUN pip install --no-cache-dir --upgrade pip && pip install --no-cache-dir -r requirements.txt
WORKDIR /code
COPY ./app /code/app
# Change ownership and switch to non-root user
RUN chown -R appuser:appuser /code
USER appuser
# Expose port 80
EXPOSE 8000
# Run Gunicorn with Uvicorn worker
CMD ["gunicorn", "app.main:app", "--workers", "3", "--worker-class", "uvicorn.workers.UvicornWorker","--timeout","3000", "--bind", "0.0.0.0:8000"]