Austim-Final-Space / Dockerfile
codewithharsha's picture
Create Dockerfile
daaec55 verified
# Use an official Python runtime as a parent image
FROM python:3.10-slim
# Set the working directory in the container
WORKDIR /code
# Copy the requirements file into the container at /code
COPY ./requirements.txt /code/requirements.txt
# Install any needed packages specified in requirements.txt
# --no-cache-dir reduces image size, --upgrade ensures latest pip
RUN pip install --no-cache-dir --upgrade pip && \
pip install --no-cache-dir -r /code/requirements.txt
# Copy the rest of the application code into the container at /code
# This includes your main.py (or app.py) and vgg_model50.h5
COPY . /code/
# Expose the port the app runs on (Hugging Face Spaces often uses 7860 by default)
EXPOSE 7860
# Command to run the application using uvicorn
# Ensure 'main:app' matches your Python filename (main.py) and FastAPI app instance name (app = FastAPI())
# If you renamed main.py to app.py, use 'app:app' instead.
# Using --host 0.0.0.0 makes it accessible from outside the container.
# Using --port 7860 matches the EXPOSE directive and HF default.
CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "7860"]