bodybuilding-pose-app / Dockerfile
Sean Carnahan
Fix HF Spaces deployment: Add proper path handling and model loading
fef15d6
raw
history blame
948 Bytes
FROM python:3.10-slim
WORKDIR /code
# Install system dependencies
RUN apt-get update && apt-get install -y \
libgl1-mesa-glx \
libglib2.0-0 \
&& rm -rf /var/lib/apt/lists/*
# Copy requirements first to leverage Docker cache
COPY requirements.txt .
RUN pip install --no-cache-dir -r requirements.txt
# Create necessary directories with proper permissions
RUN mkdir -p /code/static/uploads \
&& mkdir -p /code/logs \
&& mkdir -p /code/external/BodybuildingPoseClassifier \
&& chmod -R 777 /code/static/uploads \
&& chmod -R 777 /code/logs \
&& chmod -R 777 /code/external
# Copy the model file first
COPY external/BodybuildingPoseClassifier/bodybuilding_pose_classifier.h5 /code/external/BodybuildingPoseClassifier/
# Copy the rest of the application
COPY . .
# Set environment variables
ENV PYTHONUNBUFFERED=1
ENV FLASK_APP=app.py
# Expose the port
EXPOSE 7860
# Run the application
CMD ["python", "app.py"]