generated from kyegomez/Python-Package-Template
-
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Your Name
committed
Nov 23, 2024
1 parent
98c8fbf
commit f9d970c
Showing
1 changed file
with
29 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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)"] |