Add live update

This commit is contained in:
hlohaus
2025-06-13 08:11:02 +02:00
parent f71a729948
commit 1525fcd3e0
5 changed files with 25 additions and 8 deletions

View File

@@ -112,11 +112,10 @@ docker run -p 8080:8080 -p 7900:7900 \
mkdir -p ${PWD}/har_and_cookies ${PWD}/generated_media
chown -R 1000:1000 ${PWD}/har_and_cookies ${PWD}/generated_media
docker run \
-p 1337:1337 \
-p 1337:1337 -p 8080:1337 \
-v ${PWD}/har_and_cookies:/app/har_and_cookies \
-v ${PWD}/generated_media:/app/generated_media \
hlohaus789/g4f:latest-slim \
/bin/sh -c 'rm -rf /app/g4f && pip install -U g4f[slim] && python -m g4f --debug'
hlohaus789/g4f:latest-slim
```
5. **Access the Client Interface:**

View File

@@ -7,9 +7,9 @@ services:
build:
context: .
dockerfile: docker/Dockerfile-slim
command: python -m g4f --debug --port 8080
volumes:
- .:/app
- ./generated_media:/app/generated_media
- ./har_and_cookies:/app/har_and_cookies
ports:
- '8080:8080'
- '1337:8080'

View File

@@ -31,7 +31,8 @@ ENV HOME /home/$G4F_USER
ENV PATH "${HOME}/.local/bin:${PATH}"
RUN git clone https://github.com/xtekky/gpt4free.git $G4F_DIR
RUN crontab docker/update-cron
RUN printf "0 * * * * python -m etc.update\n" > cronfile
RUN crontab cronfile
RUN pip install --no-cache-dir -r requirements-slim.txt
CMD python -m g4f --debug --reload

View File

@@ -1,2 +0,0 @@
0 * * * * g4f python -m etc.update
#

19
etc/tool/update.py Normal file
View File

@@ -0,0 +1,19 @@
import os
from g4f import version
from subprocess import call, STDOUT
if __name__ == "__main__":
if not os.getenv("G4F_LIVE"):
print("Live mode is not enabled. Exiting update script.")
exit(0)
command = ["git", "fetch"]
call(command, stderr=STDOUT)
command = ["git", "reset", "--hard", "master"]
call(command, stderr=STDOUT)
command = ["git" ,"pull", "origin", "main"]
call(command, stderr=STDOUT)
current_version = version.get_git_version()
with open("g4f/debug.py", "a") as f:
f.write(f"\nversion: str = '{current_version}'\n")
command = ["pip", "install", "-U", "-r" , "requirements-slim.txt"]
call(command, stderr=STDOUT)