Create Dockerfile
Browse files- Dockerfile +43 -0
Dockerfile
ADDED
@@ -0,0 +1,43 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# Use an official Python runtime as a parent image
|
2 |
+
# Using a slim image reduces the final size
|
3 |
+
FROM python:3.10-slim
|
4 |
+
|
5 |
+
# Set the working directory in the container
|
6 |
+
WORKDIR /code
|
7 |
+
|
8 |
+
# Install system dependencies
|
9 |
+
# - Update apt package list
|
10 |
+
# - Install ffmpeg (essential for the application) and git (often useful for pip installs)
|
11 |
+
# - Clean up apt cache to reduce image size
|
12 |
+
RUN apt-get update && \
|
13 |
+
apt-get install -y --no-install-recommends ffmpeg git && \
|
14 |
+
apt-get clean && \
|
15 |
+
rm -rf /var/lib/apt/lists/*
|
16 |
+
|
17 |
+
# Copy the requirements file into the container at /code
|
18 |
+
# Copying this separately allows Docker to cache the pip install layer
|
19 |
+
COPY requirements.txt .
|
20 |
+
|
21 |
+
# Install any needed packages specified in requirements.txt
|
22 |
+
# --no-cache-dir reduces image size by not storing the pip cache
|
23 |
+
# --upgrade pip ensures the latest pip is used
|
24 |
+
RUN pip install --no-cache-dir --upgrade pip && \
|
25 |
+
pip install --no-cache-dir -r requirements.txt
|
26 |
+
|
27 |
+
# Copy the rest of the application code (app.py) into the container at /code
|
28 |
+
COPY app.py .
|
29 |
+
|
30 |
+
# Make port 8000 available to the world outside this container
|
31 |
+
# Hugging Face Spaces typically expects apps to run on 7860, but uvicorn defaults to 8000.
|
32 |
+
# FastAPI/Uvicorn standard is 8000. HF Spaces should map correctly.
|
33 |
+
# If you encounter issues, you might need to change this and the CMD port to 7860.
|
34 |
+
EXPOSE 8000
|
35 |
+
|
36 |
+
# Define environment variable (optional, can be set at runtime too)
|
37 |
+
# ENV HF_HOME=/data # Example if models needed downloading, not relevant here.
|
38 |
+
|
39 |
+
# Run app.py when the container launches using uvicorn
|
40 |
+
# --host 0.0.0.0 makes the server accessible from outside the container
|
41 |
+
# --port 8000 specifies the port to run on inside the container
|
42 |
+
# app:app tells uvicorn to run the 'app' variable (your FastAPI instance) from the 'app.py' file
|
43 |
+
CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "8000"]
|