Spaces:
Build error
Build error
Regino commited on
Commit Β·
8faa6ae
1
Parent(s): 95a3efa
fixed permission
Browse files1234569 unmodified lines161718192021222324252627282930313233343536373839404142431 unmodified line4546474849FROM python:3.9-slimWORKDIR /app# Install system dependencies required by OpenCV and other build tools# libgl1-mesa-glx: Provides libGL.so.1 (OpenGL library) - THIS IS THE KEY FIX9 unmodified lineslibsm6 \libxrender1 \ffmpeg \# Clean up apt caches to reduce image size&& rm -rf /var/lib/apt/lists/*# Copy your requirements.txt fileCOPY requirements.txt ./# Install Python dependencies from requirements.txtRUN pip3 install --no-cache-dir -r requirements.txt# Copy your application source code and assets# This assumes your project structure looks something like this:# project_root/# βββ src/# β βββ streamlit_app.py (your app.py renamed/moved to here)# βββ models/# β βββ emotion_model_best.h5# βββ cascades/# β βββ haarcascade_frontalface_default.xml# βββ requirements.txt# βββ Dockerfile## COPY . . copies everything from your project_root into /app in the container.COPY . .EXPOSE 85011 unmodified lineHEALTHCHECK CMD curl --fail http://localhost:8501/_stcore/health# Ensure the entrypoint path is correct for your app within the container# Based on your structure, it's inside 'src/'ENTRYPOINT ["streamlit", "run", "src/streamlit_app.py", "--server.port=8501", "--server.address=0.0.0.0"]123456789 unmodified lines18192021222324252627282930313233343536373839404142434445464748495051525354551 unmodified line5758596061FROM python:3.9-slim# Define arguments for user ID and group ID (optional, but good for consistency)ARG UID=1000ARG GID=1000# Install system dependencies required by OpenCV and other build tools# libgl1-mesa-glx: Provides libGL.so.1 (OpenGL library) - THIS IS THE KEY FIX9 unmodified lineslibsm6 \libxrender1 \ffmpeg \# Add tools for user managementuseradd \# Clean up apt caches to reduce image size&& rm -rf /var/lib/apt/lists/*# Create a non-root user and group# -m: create home directory# -u ${UID}: assign specific UID (optional, but good for host volume mounting)# -g appgroup: assign to appgroupRUN groupadd -g ${GID} appgroup && \useradd -m -u ${UID} -g appgroup appuser# Set the HOME environment variable for the new userENV HOME /home/appuser# Set the working directory for the application# We'll put it in /app and then change ownership so the non-root user can write to itWORKDIR /app# Copy your requirements.txt file and install Python dependencies (as root, for system-wide install)COPY requirements.txt .RUN pip3 install --no-cache-dir -r requirements.txt# Change ownership of the /app directory to the new non-root user# This is crucial so that the 'appuser' can read/write in its working directoryRUN chown -R appuser:appgroup /app# Switch to the non-root user for subsequent commandsUSER appuser# Copy your application source code and assets into the /app directory# Now, these files will be owned by 'appuser'COPY . .EXPOSE 85011 unmodified lineHEALTHCHECK CMD curl --fail http://localhost:8501/_stcore/health# Ensure the entrypoint path is correct for your app within the container# Based on your structure, it's inside 'src/' relative to the WORKDIR /appENTRYPOINT ["streamlit", "run", "src/streamlit_app.py", "--server.port=8501", "--server.address=0.0.0.0"]
Dockerfile+30-18