-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathDockerfile
41 lines (33 loc) · 940 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
41
# Use Python 3.12 base image
FROM python:3.12-slim
# Set environment variables
ENV PYTHONUNBUFFERED=1 \
PYTHONDONTWRITEBYTECODE=1 \
PYTHONPATH="/project:$PYTHONPATH"
WORKDIR /project
# Create non-root user
RUN useradd -r -s /bin/false appuser && \
mkdir -p /project && \
mkdir -p /home/appuser/.cache && \
chmod -R 777 /home/appuser/.cache && \
chown -R appuser:appuser /project && \
chown -R appuser:appuser /home/appuser
# Install dependencies
RUN pip install --no-cache-dir \
uvicorn[standard] \
pytest \
pytest-asyncio \
pytest-docker \
httpx \
aiosqlite \
sqlmodel \
fastapi
# Copy the project files
COPY --chown=appuser:appuser project/ ./
# Switch to non-root user
USER appuser
# Expose the port
EXPOSE 8000
# Default command
CMD ["uvicorn", "app.main:app", "--host", "0.0.0.0", "--port", "8000", \
"--workers", "4", "--loop", "uvloop", "--http", "httptools"]