XFE Git
XFE Studio Git
Git 首页 全局搜索
XFE 主站 文档 NuGet
公开
关注 0 Fork 0 Star 1
返回提交历史

XFEstudio/gpt4free

Change default port for gui Change default host for api Disable gui in build Add custom docker user

b2d02ed6
Heiner Lohaus <hlohaus@users.noreply.github.com>
提交于

代码差异

7 个文件 +48 -27
Modified docker-compose.yml +1 -1
@@ -10,6 +10,6 @@ services:
10 10 volumes:
11 11 - .:/app
12 12 ports:
13 - '8080:80'
13 - '8080:8080'
14 14 - '1337:1337'
15 15 - '7900:7900'
Modified docker/Dockerfile +28 -6
@@ -1,13 +1,27 @@
1 1 FROM selenium/node-chrome
2 2
3 3 ENV SE_SCREEN_WIDTH 1850
4 ENV G4F_LOGIN_URL http://localhost:7900/?autoconnect=1&resize=scale&password=secret
5 4 ENV PYTHONUNBUFFERED 1
5 ENV G4F_DIR /app
6 ENV G4F_LOGIN_URL http://localhost:7900/?autoconnect=1&resize=scale&password=secret
6 7 ARG G4F_VERSION
7 8 ENV G4F_VERSION ${G4F_VERSION}
9 ARG G4F_USER
10 ENV G4F_USER ${G4F_USER:-g4f}
11 ARG G4F_USER_ID
12 ENV G4F_USER_ID ${G4F_USER_ID:-1000}
13 ARG G4F_NO_GUI
14 ENV G4F_NO_GUI ${G4F_NO_GUI}
15 ENV HOME /home/$G4F_USER
8 16
9 17 USER root
10 18
19 # If docker compose, install git
20 RUN if [ "$G4F_VERSION" = "" ] ; then \
21 apt-get -qqy update && \
22 apt-get -qqy install git \
23 ; fi
24
11 25 # Python packages
12 26 RUN apt-get -qqy update \
13 27 && apt-get -qqy install \
@@ -22,24 +36,32 @@ RUN rm -rf /var/lib/apt/lists/* /var/cache/apt/* \
22 36
23 37 # Update entrypoint
24 38 COPY docker/supervisor.conf /etc/supervisor/conf.d/selenium.conf
39 COPY docker/supervisor-gui.conf /etc/supervisor/conf.d/gui.conf
40
41 # If no gui
42 RUN if [ "$G4F_NO_GUI" ] ; then \
43 rm /etc/supervisor/conf.d/gui.conf \
44 ; fi
25 45
26 46 # Change background image
27 47 COPY docker/background.png /usr/share/images/fluxbox/ubuntu-light.png
28 48
29 49 # Switch user
30 USER 1200
50 RUN groupadd -g $G4F_USER_ID $G4F_USER
51 RUN useradd -rm -G sudo -u $G4F_USER_ID -g $G4F_USER_ID $G4F_USER
52 USER $G4F_USER_ID
31 53
32 54 # Set the working directory in the container.
33 WORKDIR /app
55 WORKDIR $G4F_DIR
34 56
35 57 # Copy the project's requirements file into the container.
36 COPY requirements.txt /app/
58 COPY requirements.txt $G4F_DIR
37 59
38 60 # Upgrade pip for the latest features and install the project's Python dependencies.
39 61 RUN pip install --upgrade pip && pip install -r requirements.txt
40 62
41 63 # Copy the entire package into the container.
42 COPY g4f /app/g4f
64 ADD --chown=$G4F_USER g4f $G4F_DIR/
43 65
44 66 # Expose ports
45 EXPOSE 80 1337
67 EXPOSE 8080 1337
Added docker/supervisor-gui.conf +12 -0
@@ -0,0 +1,12 @@
1 [program:g4f-gui]
2 priority=15
3 command=python -m g4f.cli gui
4 directory=/app
5 stopasgroup=true
6 autostart=true
7 autorestart=true
8
9 ;Logs (all Hub activity redirected to stdout so it can be seen through "docker logs"
10 redirect_stderr=true
11 stdout_logfile=/dev/stdout
12 stdout_logfile_maxbytes=0
Modified docker/supervisor.conf +0 -13
@@ -57,19 +57,6 @@ stopasgroup=true
57 57 autostart=true
58 58 autorestart=true
59 59
60 ;Logs (all Hub activity redirected to stdout so it can be seen through "docker logs"
61 redirect_stderr=true
62 stdout_logfile=/dev/stdout
63 stdout_logfile_maxbytes=0
64
65 [program:g4f-gui]
66 priority=15
67 command=python -m g4f.cli gui
68 directory=/app
69 stopasgroup=true
70 autostart=true
71 autorestart=true
72
73 60 ;Logs (all Hub activity redirected to stdout so it can be seen through "docker logs"
74 61 redirect_stderr=true
75 62 stdout_logfile=/dev/stdout
Modified g4f/cli.py +1 -1
@@ -15,7 +15,7 @@ def main():
15 15 parser = argparse.ArgumentParser(description="Run gpt4free")
16 16 subparsers = parser.add_subparsers(dest="mode", help="Mode to run the g4f in.")
17 17 api_parser=subparsers.add_parser("api")
18 api_parser.add_argument("--bind", default="127.0.0.1:1337", help="The bind string.")
18 api_parser.add_argument("--bind", default="0.0.0.0:1337", help="The bind string.")
19 19 api_parser.add_argument("--debug", type=bool, default=False, help="Enable verbose logging")
20 20 api_parser.add_argument("--ignored-providers", nargs="+", choices=[provider.name for provider in IgnoredProviders],
21 21 default=[], help="List of providers to ignore when processing request.")
Modified g4f/debug.py +5 -5
@@ -1,6 +1,6 @@
1 1 from os import environ
2 2 from requests import get
3 from importlib.metadata import version, PackageNotFoundError
3 from importlib.metadata import version as get_package_version, PackageNotFoundError
4 4 from subprocess import check_output, CalledProcessError, PIPE
5 5 from .errors import VersionNotFoundError
6 6
@@ -10,7 +10,7 @@ version_check = True
10 10 def get_version() -> str:
11 11 # Read from package manager
12 12 try:
13 return version("g4f")
13 return get_package_version("g4f")
14 14 except PackageNotFoundError:
15 15 pass
16 16 # Read from docker environment
@@ -33,7 +33,7 @@ def check_pypi_version() -> None:
33 33 try:
34 34 version = get_version()
35 35 latest_version = get_lastet_version()
36 if version != latest_version:
37 print(f'New pypi version: {latest_version} (current: {version}) | pip install -U g4f')
36 38 except Exception as e:
37 print(f'Failed to check g4f pypi version: {e}')
38 if version != latest_version:
39 print(f'New pypi version: {latest_version} (current: {version}) | pip install -U g4f')
39 print(f'Failed to check g4f pypi version: {e}')
Modified g4f/gui/run.py +1 -1
@@ -6,7 +6,7 @@ from g4f.gui import run_gui
6 6 def gui_parser():
7 7 parser = ArgumentParser(description="Run the GUI")
8 8 parser.add_argument("-host", type=str, default="0.0.0.0", help="hostname")
9 parser.add_argument("-port", type=int, default=80, help="port")
9 parser.add_argument("-port", type=int, default=8080, help="port")
10 10 parser.add_argument("-debug", action="store_true", help="debug mode")
11 11 return parser
12 12