Spaces:
Paused
Paused
Create Dockerfile
Browse files- Dockerfile +29 -0
Dockerfile
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Use an official Python runtime as a parent image.
|
| 2 |
+
# Using python:3.9-slim is a good balance of features and image size.
|
| 3 |
+
FROM python:3.9-slim
|
| 4 |
+
|
| 5 |
+
# Set the working directory inside the container to /code
|
| 6 |
+
WORKDIR /code
|
| 7 |
+
|
| 8 |
+
# Copy the requirements file into the container at /code
|
| 9 |
+
# This is done first to leverage Docker's layer caching.
|
| 10 |
+
# The expensive pip install step will only be re-run if requirements.txt changes.
|
| 11 |
+
COPY ./requirements.txt /code/requirements.txt
|
| 12 |
+
|
| 13 |
+
# Install any needed packages specified in requirements.txt
|
| 14 |
+
# --no-cache-dir: Disables the cache to keep the image size smaller.
|
| 15 |
+
# --upgrade: Ensures we get the latest specified versions.
|
| 16 |
+
RUN pip install --no-cache-dir --upgrade -r /code/requirements.txt
|
| 17 |
+
|
| 18 |
+
# Copy the rest of the application code (the 'app' directory) into the container at /code
|
| 19 |
+
COPY ./app /code/app
|
| 20 |
+
|
| 21 |
+
# Make port 7860 available to the world outside this container.
|
| 22 |
+
# Hugging Face Spaces expects apps to listen on this port.
|
| 23 |
+
EXPOSE 7860
|
| 24 |
+
|
| 25 |
+
# Define the command to run your app using uvicorn.
|
| 26 |
+
# This tells uvicorn to run the 'app' object from the 'app.main' module.
|
| 27 |
+
# --host 0.0.0.0: Makes the server accessible from outside the container.
|
| 28 |
+
# --port 7860: The port to listen on.
|
| 29 |
+
CMD ["uvicorn", "app.main:app", "--host", "0.0.0.0", "--port", "7860"]
|