summaryrefslogtreecommitdiffstats
path: root/docker
diff options
context:
space:
mode:
authorHeiner Lohaus <hlohaus@users.noreply.github.com>2024-11-17 11:06:37 +0100
committerHeiner Lohaus <hlohaus@users.noreply.github.com>2024-11-17 11:06:37 +0100
commitea1448001df9c66f05a52618eb3e40a88df5efe8 (patch)
tree3f113ea8beb7c43920871019512aeb8de9d1b4f7 /docker
parentFix api streaming, fix AsyncClient (#2357) (diff)
downloadgpt4free-ea1448001df9c66f05a52618eb3e40a88df5efe8.tar
gpt4free-ea1448001df9c66f05a52618eb3e40a88df5efe8.tar.gz
gpt4free-ea1448001df9c66f05a52618eb3e40a88df5efe8.tar.bz2
gpt4free-ea1448001df9c66f05a52618eb3e40a88df5efe8.tar.lz
gpt4free-ea1448001df9c66f05a52618eb3e40a88df5efe8.tar.xz
gpt4free-ea1448001df9c66f05a52618eb3e40a88df5efe8.tar.zst
gpt4free-ea1448001df9c66f05a52618eb3e40a88df5efe8.zip
Diffstat (limited to 'docker')
-rw-r--r--docker/Dockerfile1
-rw-r--r--docker/Dockerfile-slim68
-rwxr-xr-xdocker/supervisor-api.conf12
-rwxr-xr-xdocker/supervisor-gui.conf2
-rwxr-xr-xdocker/supervisor.conf15
5 files changed, 83 insertions, 15 deletions
diff --git a/docker/Dockerfile b/docker/Dockerfile
index eb03390c..625312e2 100644
--- a/docker/Dockerfile
+++ b/docker/Dockerfile
@@ -40,6 +40,7 @@ RUN apt-get -qqy update \
# Update entrypoint
COPY docker/supervisor.conf /etc/supervisor/conf.d/selenium.conf
+COPY docker/supervisor-api.conf /etc/supervisor/conf.d/api.conf
COPY docker/supervisor-gui.conf /etc/supervisor/conf.d/gui.conf
# If no gui
diff --git a/docker/Dockerfile-slim b/docker/Dockerfile-slim
new file mode 100644
index 00000000..6c0afc64
--- /dev/null
+++ b/docker/Dockerfile-slim
@@ -0,0 +1,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 \ No newline at end of file
diff --git a/docker/supervisor-api.conf b/docker/supervisor-api.conf
new file mode 100755
index 00000000..74572634
--- /dev/null
+++ b/docker/supervisor-api.conf
@@ -0,0 +1,12 @@
+[program:g4f-api]
+priority=15
+command=python -m g4f.cli api
+directory=/app
+stopasgroup=true
+autostart=true
+autorestart=true
+
+;Logs (all Hub activity redirected to stdout so it can be seen through "docker logs"
+redirect_stderr=true
+stdout_logfile=/dev/stdout
+stdout_logfile_maxbytes=0 \ No newline at end of file
diff --git a/docker/supervisor-gui.conf b/docker/supervisor-gui.conf
index 44273c67..0c77ffc5 100755
--- a/docker/supervisor-gui.conf
+++ b/docker/supervisor-gui.conf
@@ -1,6 +1,6 @@
[program:g4f-gui]
priority=15
-command=python -m g4f.cli gui
+command=python -m g4f.cli gui -debug
directory=/app
stopasgroup=true
autostart=true
diff --git a/docker/supervisor.conf b/docker/supervisor.conf
index f0f01fd1..7fd4331a 100755
--- a/docker/supervisor.conf
+++ b/docker/supervisor.conf
@@ -47,17 +47,4 @@ stderr_logfile_maxbytes=50MB
stdout_logfile_backups=5
stderr_logfile_backups=5
stdout_capture_maxbytes=50MB
-stderr_capture_maxbytes=50MB
-
-[program:g4f-api]
-priority=15
-command=python -m g4f.cli api
-directory=/app
-stopasgroup=true
-autostart=true
-autorestart=true
-
-;Logs (all Hub activity redirected to stdout so it can be seen through "docker logs"
-redirect_stderr=true
-stdout_logfile=/dev/stdout
-stdout_logfile_maxbytes=0 \ No newline at end of file
+stderr_capture_maxbytes=50MB \ No newline at end of file