Spaces:
Sleeping
Sleeping
File size: 1,450 Bytes
cd361a4 e2492f0 cd361a4 e2492f0 cd361a4 e2492f0 e2839df e2492f0 cd361a4 e2492f0 5dd4f2e fef15d6 e2839df 8e844fb 5dd4f2e fef15d6 e2839df fef15d6 2d71013 cd361a4 fded136 8e844fb 2d71013 cd361a4 e2839df e2492f0 cd361a4 e2492f0 8e844fb cd361a4 |
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 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 |
FROM python:3.10-slim
WORKDIR /code
# Install system dependencies
RUN apt-get update && apt-get install -y \
libgl1-mesa-glx \
libglib2.0-0 \
ffmpeg \
&& 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 \
&& mkdir -p /code/templates \
&& chown -R nobody:nogroup /code \
&& chmod -R 777 /code/static/uploads \
&& chmod -R 777 /code/logs \
&& chmod -R 777 /code/external \
&& chmod -R 777 /code/templates
# Copy the entire application first
COPY . .
# Set correct ownership and permissions after copying
RUN chown -R nobody:nogroup /code \
&& chmod -R 777 /code/static/uploads \
&& chmod -R 777 /code/logs \
&& chmod -R 777 /code/external \
&& chmod -R 777 /code/templates
# Verify model file exists and has correct permissions
RUN ls -la /code/external/BodybuildingPoseClassifier/ && \
chmod 644 /code/external/BodybuildingPoseClassifier/bodybuilding_pose_classifier.h5
# Set environment variables
ENV PYTHONUNBUFFERED=1
ENV FLASK_APP=app.py
ENV TF_CPP_MIN_LOG_LEVEL=2
# Expose the port
EXPOSE 7860
# Run the application as non-root user
USER nobody
# Run the application
CMD ["python", "app.py"] |