File size: 977 Bytes
ca72ed3 b187e4d ca72ed3 90644ee b187e4d ca72ed3 b187e4d ca72ed3 90644ee ca72ed3 90644ee ca72ed3 90644ee ca72ed3 90644ee ca72ed3 b187e4d ca72ed3 b187e4d 90644ee | 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 | # Use official Python image
FROM python:3.10-slim
# Set environment variables
ENV PYTHONDONTWRITEBYTECODE=1 \
PYTHONUNBUFFERED=1 \
PORT=7860
# Set working directory
WORKDIR /app
# Install minimal system dependencies
RUN apt-get update && apt-get install -y --no-install-recommends \
libglib2.0-0 \
&& apt-get clean && rm -rf /var/lib/apt/lists/*
# Create a non-root user and set permissions
RUN useradd -m -u 1000 user
USER user
ENV HOME=/home/user \
PATH=/home/user/.local/bin:$PATH
WORKDIR $HOME/app
# Copy requirements and install dependencies
COPY --chown=user requirements.txt .
RUN pip install --no-cache-dir --user -r requirements.txt
# Copy application code
COPY --chown=user . .
# Ensure static directories exist
RUN mkdir -p static/uploads
# Expose port
EXPOSE 7860
# Run the application
CMD ["gunicorn", "--bind", "0.0.0.0:7860", "--workers", "1", "--threads", "4", "--timeout", "120", "app:app"]
|