Dockerfile-armv7 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. FROM python:slim-bookworm
  2. ARG G4F_VERSION
  3. ARG G4F_USER=g4f
  4. ARG G4F_USER_ID=1000
  5. ARG PYDANTIC_VERSION=1.8.1
  6. ENV G4F_VERSION $G4F_VERSION
  7. ENV G4F_USER $G4F_USER
  8. ENV G4F_USER_ID $G4F_USER_ID
  9. ENV G4F_DIR /app
  10. RUN apt-get update && apt-get upgrade -y \
  11. && apt-get install -y git curl \
  12. && apt-get install --quiet --yes --no-install-recommends \
  13. build-essential libffi-dev zlib1g-dev libjpeg-dev libssl-dev pkg-config \
  14. # Add user and user group
  15. && groupadd -g $G4F_USER_ID $G4F_USER \
  16. && useradd -rm -G sudo -u $G4F_USER_ID -g $G4F_USER_ID $G4F_USER \
  17. && mkdir -p /var/log/supervisor \
  18. && chown "${G4F_USER_ID}:${G4F_USER_ID}" /var/log/supervisor \
  19. && echo "${G4F_USER}:${G4F_USER}" | chpasswd \
  20. && python -m pip install --upgrade pip
  21. USER $G4F_USER_ID
  22. WORKDIR $G4F_DIR
  23. ENV HOME /home/$G4F_USER
  24. ENV PATH "${HOME}/.local/bin:${HOME}/.cargo/bin:${PATH}"
  25. # Install rust toolchain
  26. RUN curl https://sh.rustup.rs -sSf | bash -s -- -y
  27. # Create app dir and copy the project's requirements file into it
  28. RUN mkdir -p $G4F_DIR
  29. COPY requirements-min.txt $G4F_DIR
  30. COPY requirements-slim.txt $G4F_DIR
  31. # Upgrade pip for the latest features and install the project's Python dependencies.
  32. RUN pip install --no-cache-dir -r requirements-min.txt \
  33. && pip install --no-cache-dir --no-binary setuptools \
  34. Cython==0.29.22 \
  35. setuptools \
  36. # Install PyDantic
  37. && pip install \
  38. -vvv \
  39. --no-cache-dir \
  40. --no-binary :all: \
  41. --global-option=build_ext \
  42. --global-option=-j8 \
  43. pydantic==${PYDANTIC_VERSION}
  44. RUN cat requirements-slim.txt | xargs -n 1 pip install --no-cache-dir || true
  45. # Remove build packages
  46. RUN pip uninstall --yes \
  47. Cython \
  48. setuptools
  49. USER root
  50. # Clean up build deps
  51. RUN rm --recursive --force "${HOME}/.rustup"
  52. RUN apt-get purge --auto-remove --yes \
  53. build-essential \
  54. && apt-get clean \
  55. && rm --recursive --force /var/lib/apt/lists/* /tmp/* /var/tmp/*
  56. USER $G4F_USER_ID
  57. # Copy the entire package into the container.
  58. ADD --chown=$G4F_USER:$G4F_USER g4f $G4F_DIR/g4f