Spaces:
Paused
Paused
Update Dockerfile
Browse files- Dockerfile +16 -29
Dockerfile
CHANGED
|
@@ -1,37 +1,24 @@
|
|
| 1 |
-
# Use an official Python runtime as a parent image
|
| 2 |
-
FROM python:3.
|
| 3 |
|
| 4 |
-
#
|
| 5 |
-
|
| 6 |
|
| 7 |
-
#
|
| 8 |
-
|
| 9 |
|
| 10 |
-
#
|
| 11 |
-
|
|
|
|
|
|
|
| 12 |
|
| 13 |
-
#
|
| 14 |
-
|
| 15 |
-
# This ensures that executables installed by pip (like uvicorn) can be found.
|
| 16 |
-
ENV PATH=$HOME/.local/bin:$PATH
|
| 17 |
|
| 18 |
-
#
|
| 19 |
-
ENV TRANSFORMERS_CACHE=$HOME/.cache
|
| 20 |
-
|
| 21 |
-
# Set the working directory for the application.
|
| 22 |
-
WORKDIR $HOME/app
|
| 23 |
-
|
| 24 |
-
# Copy and own the requirements file.
|
| 25 |
-
COPY --chown=user:user ./requirements.txt .
|
| 26 |
-
|
| 27 |
-
# Install Python dependencies.
|
| 28 |
-
RUN pip install --no-cache-dir --upgrade -r requirements.txt
|
| 29 |
-
|
| 30 |
-
# Copy and own the application file.
|
| 31 |
-
COPY --chown=user:user ./app.py .
|
| 32 |
-
|
| 33 |
-
# Expose the port the app will run on.
|
| 34 |
EXPOSE 7860
|
| 35 |
|
| 36 |
-
# Command to run
|
|
|
|
|
|
|
| 37 |
CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860"]
|
|
|
|
| 1 |
+
# Use an official Python runtime as a parent image
|
| 2 |
+
FROM python:3.10-slim
|
| 3 |
|
| 4 |
+
# Set the working directory in the container
|
| 5 |
+
WORKDIR /code
|
| 6 |
|
| 7 |
+
# Copy the requirements file into the container at /code
|
| 8 |
+
COPY ./requirements.txt /code/requirements.txt
|
| 9 |
|
| 10 |
+
# Install any needed packages specified in requirements.txt
|
| 11 |
+
# --no-cache-dir: Disables the cache, which reduces the image size
|
| 12 |
+
# --upgrade: Ensures we get the latest specified versions
|
| 13 |
+
RUN pip install --no-cache-dir --upgrade -r /code/requirements.txt
|
| 14 |
|
| 15 |
+
# Copy the rest of the application code into the container at /code
|
| 16 |
+
COPY . /code/
|
|
|
|
|
|
|
| 17 |
|
| 18 |
+
# Expose the port the app will run on. Hugging Face Spaces uses 7860 by default.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 19 |
EXPOSE 7860
|
| 20 |
|
| 21 |
+
# Command to run the application using uvicorn
|
| 22 |
+
# --host 0.0.0.0: Makes the server accessible from outside the container
|
| 23 |
+
# --port 7860: The port to run on
|
| 24 |
CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860"]
|