Dockerfile-slim 1.0 KB

123456789101112131415161718192021222324252627282930313233343536
  1. FROM python:slim-bookworm
  2. ARG G4F_VERSION
  3. ARG G4F_USER=g4f
  4. ARG G4F_USER_ID=1000
  5. ENV G4F_VERSION $G4F_VERSION
  6. ENV G4F_USER $G4F_USER
  7. ENV G4F_USER_ID $G4F_USER_ID
  8. ENV G4F_DIR /app
  9. RUN apt-get update && apt-get upgrade -y \
  10. && apt-get install -y git \
  11. # Add user and user group
  12. && groupadd -g $G4F_USER_ID $G4F_USER \
  13. && useradd -rm -G sudo -u $G4F_USER_ID -g $G4F_USER_ID $G4F_USER \
  14. && echo "${G4F_USER}:${G4F_USER}" | chpasswd \
  15. && python -m pip install --upgrade pip \
  16. && apt-get clean \
  17. && rm --recursive --force /var/lib/apt/lists/* /tmp/* /var/tmp/*
  18. USER $G4F_USER_ID
  19. WORKDIR $G4F_DIR
  20. ENV HOME /home/$G4F_USER
  21. ENV PATH "${HOME}/.local/bin:${PATH}"
  22. # Create app dir and copy the project's requirements file into it
  23. RUN mkdir -p $G4F_DIR
  24. COPY requirements-slim.txt $G4F_DIR
  25. # Upgrade pip for the latest features and install the project's Python dependencies.
  26. RUN pip install --no-cache-dir -r requirements-slim.txt
  27. # Copy the entire package into the container.
  28. ADD --chown=$G4F_USER:$G4F_USER g4f $G4F_DIR/g4f