-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
40 lines (30 loc) · 984 Bytes
/
Dockerfile
File metadata and controls
40 lines (30 loc) · 984 Bytes
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
# Use a lightweight official Python image
FROM python:3.11-slim
# Prevent Python from writing .pyc files
ENV PYTHONDONTWRITEBYTECODE=1
# Make Python output unbuffered (logs show immediately)
ENV PYTHONUNBUFFERED=1
# Set working directory inside container
WORKDIR /app
# Install system dependencies needed for Git and building packages
RUN apt-get update && apt-get install -y \
git \
curl \
build-essential \
libssl-dev \
libffi-dev \
&& rm -rf /var/lib/apt/lists/*
# Copy Python dependencies file first (for caching)
COPY requirements.txt .
# Upgrade pip and install dependencies
RUN pip install --upgrade pip
RUN pip install --no-cache-dir -r requirements.txt
# Copy the rest of your app code
COPY . .
# Create a non-root user for security
RUN useradd -m appuser
USER appuser
# Expose port 8000 (FastAPI default)
EXPOSE 8000
# Command to run FastAPI using Uvicorn
CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "8000", "--workers", "2"]