FROM python:3.10-slim WORKDIR /app ENV DEBIAN_FRONTEND=noninteractive RUN apt-get update && apt-get install -y --no-install-recommends \ build-essential \ curl \ ca-certificates \ git \ && rm -rf /var/lib/apt/lists/* # Create a non-root user (we'll switch to it at runtime) RUN useradd -m -u 1000 user # Copy app files and install dependencies as root to avoid permission problems COPY requirements.txt ./ RUN pip install --no-cache-dir -r requirements.txt COPY . /app RUN chown -R user:user /app COPY start.sh /app/start.sh RUN chown user:user /app/start.sh && chmod +x /app/start.sh ENV HOME=/home/user \ PATH=/home/user/.local/bin:$PATH USER user WORKDIR /app EXPOSE 7860 # Use PORT env var if provided by the platform, otherwise default to 7860 HEALTHCHECK CMD curl --fail http://localhost:${PORT:-7860}/_stcore/health || exit 1 # Use launcher so logs include environment and file listing for debugging USER user WORKDIR /app CMD ["./start.sh"]