Spaces:
Build error
Build error
Update Dockerfile
Browse files- Dockerfile +18 -11
Dockerfile
CHANGED
|
@@ -1,16 +1,23 @@
|
|
| 1 |
-
#
|
| 2 |
-
|
| 3 |
|
| 4 |
-
|
|
|
|
| 5 |
|
| 6 |
-
|
| 7 |
-
|
| 8 |
-
|
|
|
|
|
|
|
| 9 |
|
| 10 |
-
|
|
|
|
| 11 |
|
| 12 |
-
|
| 13 |
-
|
|
|
|
| 14 |
|
| 15 |
-
|
| 16 |
-
|
|
|
|
|
|
|
|
|
| 1 |
+
# 1. Use an official Python runtime as a parent image
|
| 2 |
+
FROM python:3.10-slim
|
| 3 |
|
| 4 |
+
# 2. Set the working directory in the container
|
| 5 |
+
WORKDIR /code
|
| 6 |
|
| 7 |
+
# 3. Copy the dependencies file and install them
|
| 8 |
+
# This is done in a separate step to leverage Docker's layer caching.
|
| 9 |
+
# The dependencies will only be re-installed if requirements.txt changes.
|
| 10 |
+
COPY ./requirements.txt /code/requirements.txt
|
| 11 |
+
RUN pip install --no-cache-dir --upgrade -r /code/requirements.txt
|
| 12 |
|
| 13 |
+
# 4. Copy the rest of the application's code into the container
|
| 14 |
+
COPY . /code/
|
| 15 |
|
| 16 |
+
# 5. Expose the port that the app will run on
|
| 17 |
+
# Hugging Face Spaces expect the app to listen on port 7860
|
| 18 |
+
EXPOSE 7860
|
| 19 |
|
| 20 |
+
# 6. Define the command to run your app
|
| 21 |
+
# This command starts the Uvicorn server which serves your FastAPI app.
|
| 22 |
+
# --host 0.0.0.0 makes the server accessible from outside the container.
|
| 23 |
+
CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860"]
|