From 3ac4c832febd11adf66944325c8a451bf250f27c Mon Sep 17 00:00:00 2001 From: fantasy-peak <1356346239@qq.com> Date: Fri, 4 Aug 2023 13:43:07 +0900 Subject: [PATCH] Add dockerfile --- .github/workflows/ubuntu.yaml | 26 ++++++++++++++++++-------- Dockerfile | 14 ++++++++++++++ README.md | 14 ++++++++++++++ include/cfg.h | 2 +- 4 files changed, 47 insertions(+), 9 deletions(-) create mode 100644 Dockerfile diff --git a/.github/workflows/ubuntu.yaml b/.github/workflows/ubuntu.yaml index 1e1b7de..20759e0 100644 --- a/.github/workflows/ubuntu.yaml +++ b/.github/workflows/ubuntu.yaml @@ -1,6 +1,10 @@ name: Linux -on: [push, pull_request] +on: + push: + branches: [ "main", "dev" ] + pull_request: + branches: [ "main" ] jobs: build: @@ -11,11 +15,6 @@ jobs: os: [ubuntu-22.04] steps: - # - uses: actions/checkout@v1 - # - uses: xmake-io/github-action-setup-xmake@v1 - # with: - # xmake-version: branch@master - # actions-cache-folder: '.xmake-cache' - name: Installation run: | sudo apt-get update @@ -35,5 +34,16 @@ jobs: source ~/.xmake/profile xmake build -y xmake install -o . - cd bin - ldd cpp-freegpt-webui + ldd ./bin/cpp-freegpt-webui + - name: Docker login + uses: docker/login-action@v1 + with: + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_PASSWORD }} + - name: Build the Docker image + run: | + pwd + ls + docker build . -t ${{ secrets.DOCKERHUB_USERNAME }}/freegpt:latest + - name: Docker image push + run: docker push ${{ secrets.DOCKERHUB_USERNAME }}/freegpt:latest diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..d63d478 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,14 @@ +FROM ubuntu:22.04 + +WORKDIR /app + +ADD bin /app/bin +ADD cfg /app/cfg +ADD client /app/client + +RUN ls /app/bin +RUN ls /app/cfg + +WORKDIR /app/bin + +ENTRYPOINT ["sh", "-c", "./cpp-freegpt-webui ../cfg/cpp-free-gpt.yml"] diff --git a/README.md b/README.md index c87397b..7f1a7f9 100644 --- a/README.md +++ b/README.md @@ -32,6 +32,20 @@ Access the application in your browser using the URL: ``` http://127.0.0.1:8085/chat ``` + +### Running the Docker +Pull the Docker image from Docker Hub: +``` +docker pull fantasypeak/freegpt:latest +``` + +Run the application using Docker: +``` +docker run --net=host -it --name freegpt fantasypeak/freegpt:latest +// OR +docker run -p 8858:8858 -it --name freegpt fantasypeak/freegpt:latest +``` + ### WebUI The application interface was incorporated from the [chatgpt-clone](https://github.com/xtekky/chatgpt-clone) repository. diff --git a/include/cfg.h b/include/cfg.h index 1ffe968..12be986 100644 --- a/include/cfg.h +++ b/include/cfg.h @@ -7,7 +7,7 @@ struct Config { std::size_t interval{300}; std::size_t work_thread_num{8}; std::size_t max_http_client_num{2}; - std::string host{"127.0.0.1"}; + std::string host{"0.0.0.0"}; std::string port{"8858"}; std::string chat_path{"/chat"}; std::vector providers;