Spaces:
Build error
Build error
# Base image: Python 3.9 slim version | |
FROM python:3.9-slim | |
# Set the working directory in the container | |
WORKDIR /app | |
# Install system dependencies | |
# - build-essential: for compiling Python packages if needed | |
# - curl: for the healthcheck | |
# - libgl1-mesa-glx: dependency for OpenCV (to fix libGL.so.1 error) | |
RUN apt-get update && \ | |
apt-get install -y \ | |
build-essential \ | |
curl \ | |
libgl1-mesa-glx \ | |
&& rm -rf /var/lib/apt/lists/* | |
# Copy the requirements file first to leverage Docker cache | |
COPY requirements.txt ./ | |
# Install Python dependencies | |
# Using --no-cache-dir to keep the image size smaller | |
RUN pip3 install --no-cache-dir -r requirements.txt | |
# Create necessary subdirectories within /app for your application's structure | |
# These directories will hold your models, CSS, and images | |
RUN mkdir -p /app/face_detector /app/css /app/images | |
# Copy your application files into the container, | |
# placing them in the correct subdirectories as expected by app.py | |
COPY app.py ./app.py | |
COPY deploy.prototxt /app/face_detector/deploy.prototxt | |
COPY res10_300x300_ssd_iter_140000.caffemodel /app/face_detector/res10_300x300_ssd_iter_140000.caffemodel | |
COPY mask_detector.h5 ./mask_detector.h5 | |
COPY styles.css /app/css/styles.css | |
COPY out.jpg /app/images/out.jpg # Copies the out.jpg from your repo | |
# Expose the port Streamlit runs on (default is 8501) | |
EXPOSE 8501 | |
# Healthcheck for Streamlit (optional but good practice) | |
HEALTHCHECK CMD curl --fail http://localhost:8501/_stcore/health | |
# Set the entrypoint to run the Streamlit application | |
# This will execute: streamlit run app.py --server.port=8501 --server.address=0.0.0.0 | |
ENTRYPOINT ["streamlit", "run", "app.py", "--server.port=8501", "--server.address=0.0.0.0"] |