File size: 1,336 Bytes
ff2059e 2b897f4 bcaa0a6 ff2059e 2b897f4 ff2059e 2b897f4 ff2059e bcaa0a6 ff2059e 55531a5 2b897f4 0a1a565 bcaa0a6 ff2059e bcaa0a6 ff2059e 2b897f4 039d568 |
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 |
# Use a smaller base image compatible with Spaces
FROM python:3.10-slim
# Set up environment
ENV PORT=7860
ENV SHM_SIZE="1g"
ENV DEBIAN_FRONTEND=noninteractive
WORKDIR /app
# Create a non-root user and switch to it
RUN useradd -m -u 1000 user && \
mkdir -p /app/har_and_cookies /app/generated_media && \
chown -R user:user /app
# Install required system dependencies including SSL libraries
RUN apt-get update && \
apt-get install -y --no-install-recommends \
wget \
ca-certificates \
libssl-dev \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*
# Switch to the non-root user
USER user
# Install Python dependencies with --user flag
ENV PATH="/home/user/.local/bin:${PATH}"
RUN pip install --no-cache-dir --user \
uvicorn \
fastapi \
hypercorn \
g4f[all] \
pyopenssl \
cryptography
# Ensure proper Python path configuration
ENV PYTHONPATH="${PYTHONPATH}:/home/user/.local/lib/python3.10/site-packages"
# Ensure the media directories exist with proper permissions
RUN mkdir -p /app/har_and_cookies /app/generated_media && \
chmod 755 /app/har_and_cookies /app/generated_media
# Expose the required port
EXPOSE 7860
# Correct command to run the application with limited providers and debug mode
CMD ["sh", "-c", "python -m g4f.cli api --bind 0.0.0.0:$PORT --debug "] |