blob: 6c0afc644f4840a28be8a7c2a4e661dd0bfcfed2 (
plain) (
blame)
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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
|
FROM python:bookworm
ARG G4F_VERSION
ARG G4F_USER=g4f
ARG G4F_USER_ID=1000
ARG PYDANTIC_VERSION=1.8.1
ENV G4F_VERSION $G4F_VERSION
ENV G4F_USER $G4F_USER
ENV G4F_USER_ID $G4F_USER_ID
ENV G4F_DIR /app
RUN apt-get update && apt-get upgrade -y \
&& apt-get install -y git \
&& apt-get install --quiet --yes --no-install-recommends \
build-essential \
# Add user and user group
&& groupadd -g $G4F_USER_ID $G4F_USER \
&& useradd -rm -G sudo -u $G4F_USER_ID -g $G4F_USER_ID $G4F_USER \
&& mkdir -p /var/log/supervisor \
&& chown "${G4F_USER_ID}:${G4F_USER_ID}" /var/log/supervisor \
&& echo "${G4F_USER}:${G4F_USER}" | chpasswd
USER $G4F_USER_ID
WORKDIR $G4F_DIR
ENV HOME /home/$G4F_USER
ENV PATH "${HOME}/.local/bin:${HOME}/.cargo/bin:${PATH}"
# Create app dir and copy the project's requirements file into it
RUN mkdir -p $G4F_DIR
COPY requirements-slim.txt $G4F_DIR
# Install rust toolchain
RUN curl https://sh.rustup.rs -sSf | bash -s -- -y
# Upgrade pip for the latest features and install the project's Python dependencies.
RUN python -m pip install --upgrade pip \
&& pip install --no-cache-dir \
Cython==0.29.22 \
setuptools \
# Install PyDantic
&& pip install \
-vvv \
--no-cache-dir \
--no-binary pydantic \
--global-option=build_ext \
--global-option=-j8 \
pydantic==${PYDANTIC_VERSION} \
&& pip install --no-cache-dir -r requirements-slim.txt \
# Remove build packages
&& pip uninstall --yes \
Cython \
setuptools
USER root
# Clean up build deps
RUN rustup self uninstall -y \
&& apt-get purge --auto-remove --yes \
build-essential \
&& apt-get clean \
&& rm --recursive --force /var/lib/apt/lists/* /tmp/* /var/tmp/*
USER $G4F_USER_ID
# Copy the entire package into the container.
ADD --chown=$G4F_USER:$G4F_USER g4f $G4F_DIR/g4f
|