backend-space-1 / Dockerfile
Abhik19's picture
Update Dockerfile
729dbe8 verified
Raw
History Blame Contribute Delete
756 Bytes
#Use a stable and slim Python base image
FROM python:3.9-slim
#Set the working directory inside the container to /app
WORKDIR /app
#Copy the requirements file first to leverage Docker's layer caching.
#This way, dependencies are only re-installed if requirements.txt changes.
COPY requirements.txt .
#Install the Python dependencies specified in the requirements file
RUN pip install --no-cache-dir -r requirements.txt
#Copy all other application files (app.py, model .joblib file, etc.) into the container
COPY . .
#Expose the port that Hugging Face Spaces uses to run the application
EXPOSE 7860
#Define the command to run the application using Gunicorn, a production-ready web server.
CMD ["gunicorn", "-w", "2", "-b", "0.0.0.0:7860", "app:app"]