Skip to content

Commit

Permalink
[DOCKER]
Browse files Browse the repository at this point in the history
  • Loading branch information
Your Name committed Nov 23, 2024
1 parent 98c8fbf commit f9d970c
Showing 1 changed file with 29 additions and 0 deletions.
29 changes: 29 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# Use the official Python 3.12 image
FROM python:3.12-slim

# Set environment variables
ENV PYTHONDONTWRITEBYTECODE=1
ENV PYTHONUNBUFFERED=1

# Set the working directory
WORKDIR /app

# Install system dependencies for faster builds
RUN apt-get update && apt-get install -y --no-install-recommends \
gcc \
libpq-dev \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*

# Copy only requirements first for better caching
COPY requirements.txt .

# Install Python dependencies
RUN pip install --upgrade pip && \
pip install -r requirements.txt

# Copy the application code
COPY . .

# Command to run the application with dynamic worker count
CMD ["sh", "-c", "uvicorn api:app --host 0.0.0.0 --port 8000 --workers $(nproc)"]

0 comments on commit f9d970c

Please sign in to comment.