Spaces:
Running
Running
Create Dockerfile
Browse files- Dockerfile +34 -0
Dockerfile
ADDED
@@ -0,0 +1,34 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# Use an official Python runtime as a parent image
|
2 |
+
# Using a specific version like 3.10 or 3.11 is recommended over 'latest'
|
3 |
+
FROM python:3.10-slim
|
4 |
+
|
5 |
+
# Set environment variables
|
6 |
+
ENV PYTHONDONTWRITEBYTECODE 1 # Prevents python from writing .pyc files
|
7 |
+
ENV PYTHONUNBUFFERED 1 # Ensures logs print directly to terminal
|
8 |
+
ENV PORT=7860 # Define the port the app will run on *inside* the container
|
9 |
+
|
10 |
+
# Set the working directory in the container
|
11 |
+
WORKDIR /app
|
12 |
+
|
13 |
+
# Install system dependencies if needed (e.g., build tools) - add if required later
|
14 |
+
# RUN apt-get update && apt-get install -y --no-install-recommends some-package && rm -rf /var/lib/apt/lists/*
|
15 |
+
|
16 |
+
# Copy the requirements file into the container
|
17 |
+
COPY requirements.txt .
|
18 |
+
|
19 |
+
# Install Python dependencies
|
20 |
+
# --no-cache-dir reduces image size
|
21 |
+
RUN pip install --no-cache-dir --upgrade pip && \
|
22 |
+
pip install --no-cache-dir -r requirements.txt
|
23 |
+
|
24 |
+
# Copy the rest of the application code into the container
|
25 |
+
COPY . .
|
26 |
+
|
27 |
+
# Expose the port the app runs on
|
28 |
+
# This informs Docker that the container listens on this port
|
29 |
+
EXPOSE ${PORT}
|
30 |
+
|
31 |
+
# Define the command to run the application
|
32 |
+
# Use 0.0.0.0 to listen on all network interfaces inside the container
|
33 |
+
# Uvicorn will listen on the port defined by the $PORT env var (7860)
|
34 |
+
CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "7860"]
|