File size: 924 Bytes
5ae7c8f | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 | # Use the official lightweight Python image.
# https://hub.docker.com/_/python
FROM python:3.9-slim
# Set the working directory to /app
WORKDIR /app
# Copy the requirements file into the container at /app
COPY requirements.txt .
# Install any needed packages specified in requirements.txt
RUN pip install --no-cache-dir -r requirements.txt
# Copy the rest of the application code
COPY . .
# Create the SQLite database directory permissions if needed (HF spaces are writable in /app)
# But standard SQLite file in CWD is fine.
# Make sure the model is generated during build or on startup
# We run the training script during build to ensure model.pkl exists
RUN python -c "import model; model.train_model()"
# Expose port 7860 (Hugging Face Spaces default port)
EXPOSE 7860
# Run commands to start the server
# binding to 0.0.0.0 is crucial for Docker containers
CMD ["python", "app.py"]
|