Spaces:
Sleeping
Sleeping
Create Dockerfile
Browse files- Dockerfile +29 -0
Dockerfile
ADDED
@@ -0,0 +1,29 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# Use an official Python runtime as a parent image
|
2 |
+
FROM python:3.9-slim
|
3 |
+
|
4 |
+
# Prevent Python from writing .pyc files to disk and buffer stdout/stderr
|
5 |
+
ENV PYTHONDONTWRITEBYTECODE 1
|
6 |
+
ENV PYTHONUNBUFFERED 1
|
7 |
+
|
8 |
+
# Set working directory
|
9 |
+
WORKDIR /app
|
10 |
+
|
11 |
+
# Install build dependencies (if required)
|
12 |
+
RUN apt-get update && apt-get install -y --no-install-recommends \
|
13 |
+
build-essential \
|
14 |
+
&& rm -rf /var/lib/apt/lists/*
|
15 |
+
|
16 |
+
# Copy requirements.txt first to leverage Docker cache
|
17 |
+
COPY requirements.txt .
|
18 |
+
|
19 |
+
# Upgrade pip and install Python dependencies
|
20 |
+
RUN pip install --upgrade pip && pip install -r requirements.txt
|
21 |
+
|
22 |
+
# Copy the rest of the application code
|
23 |
+
COPY . .
|
24 |
+
|
25 |
+
# Expose port 8000 for the FastAPI app
|
26 |
+
EXPOSE 8000
|
27 |
+
|
28 |
+
# Command to run the FastAPI app using uvicorn
|
29 |
+
CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "8000"]
|