diff --git a/README.md b/README.md index f4973c7a..36a1f2d8 100644 --- a/README.md +++ b/README.md @@ -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:** diff --git a/docker-compose-slim.yml b/docker-compose-slim.yml index 39754f72..5976a524 100644 --- a/docker-compose-slim.yml +++ b/docker-compose-slim.yml @@ -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' \ No newline at end of file diff --git a/docker/Dockerfile-slim b/docker/Dockerfile-slim index b6ba960f..ce756369 100644 --- a/docker/Dockerfile-slim +++ b/docker/Dockerfile-slim @@ -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 \ No newline at end of file diff --git a/docker/update-cron b/docker/update-cron deleted file mode 100644 index c5240dde..00000000 --- a/docker/update-cron +++ /dev/null @@ -1,2 +0,0 @@ -0 * * * * g4f python -m etc.update -# \ No newline at end of file diff --git a/etc/tool/update.py b/etc/tool/update.py new file mode 100644 index 00000000..58f3e080 --- /dev/null +++ b/etc/tool/update.py @@ -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) \ No newline at end of file