From 054f29ea3971d3b5e3e91223e97439649b5e62c3 Mon Sep 17 00:00:00 2001 From: Kumi Date: Tue, 23 Apr 2024 09:21:05 +0200 Subject: [PATCH] feat: Add Docker CI/CD and update docs for Docker usage Introduced a new Docker CI/CD workflow to automatically build and push images to Docker Hub on pushes to the 'docker' branch. This automation ensures that the latest version of the bot is readily available for deployment, facilitating easier distribution and deployment for users. The README.md has been updated to improve clarity around installation methods, emphasizing PyPI as the recommended installation method while expanding on Docker usage. It now includes detailed instructions for Docker Hub images, local image building, and Docker Compose deployment, catering to a broader range of users and deployment scenarios. This update aims to make the bot more accessible and manageable by providing clear, step-by-step guidance for different deployment strategies. Related to these changes, the documentation has been restructured to better organize information related to configuration and running the bot, ensuring users have a smoother experience setting up and deploying it in their environment. These changes reflect our commitment to enhancing user experience and streamlining deployment processes, making it easier for users to adopt and maintain the matrix-gptbot in various environments. --- .forgejo/workflows/docker-latest.yml | 29 +++++++++++ README.md | 72 ++++++++++++++++++++++++++-- 2 files changed, 96 insertions(+), 5 deletions(-) create mode 100644 .forgejo/workflows/docker-latest.yml diff --git a/.forgejo/workflows/docker-latest.yml b/.forgejo/workflows/docker-latest.yml new file mode 100644 index 0000000..cf341dc --- /dev/null +++ b/.forgejo/workflows/docker-latest.yml @@ -0,0 +1,29 @@ +name: Docker CI/CD + +on: + push: + branches: + - 'docker' + +jobs: + docker: + runs-on: ubuntu-latest + steps: + - + name: Set up QEMU + uses: docker/setup-qemu-action@v3 + - + name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + - + name: Login to Docker Hub + uses: docker/login-action@v3 + with: + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_TOKEN }} + - + name: Build and push + uses: docker/build-push-action@v5 + with: + push: true + tags: kumitterer/matrix-gptbot:latest \ No newline at end of file diff --git a/README.md b/README.md index f5ec6aa..aafbe3c 100644 --- a/README.md +++ b/README.md @@ -31,7 +31,9 @@ system features. ### Production -The easiest way to install the bot is to use pip to install it from pypi. +#### PyPI + +The recommended way to install the bot is to use pip to install it from PyPI. ```shell # If desired, activate a venv first @@ -50,10 +52,65 @@ for all available features. You can also use `pip install git+https://git.private.coffee/privatecoffee/matrix-gptbot.git` to install the latest version from the Git repository. -#### Configuration +#### Docker -The bot requires a configuration file to be present in the working directory. -Copy the provided `config.dist.ini` to `config.ini` and edit it to your needs. +##### From Docker Hub + +A Docker image is available on Docker Hub. You can use it to run the bot in a +Docker container. + +```shell +# Create a config file from the provided example +cp config.dist.ini config.ini +# Edit the config file to your needs + +# Run the bot +docker run -v config.ini:/app/config.ini kumitterer/matrix-gptbot +``` + +##### Building the image + +Alternatively, you can use the provided `Dockerfile` to build and run the bot +locally. + +```shell +# Clone the repository +git clone https://git.private.coffee/privatecoffee/matrix-gptbot.git +cd matrix-gptbot + +# Build the Docker image +docker build -t matrix-gptbot . + +# Create a config file +cp config.dist.ini config.ini +# Edit the config file to your needs + +# Run the bot +docker run -v config.ini:/app/config.ini matrix-gptbot +``` + +##### Docker Compose + +A `docker-compose.yml` file is provided that you can use to run the bot with +Docker Compose. You will need to create a `config.ini` file as described above. + +```shell +# Clone the repository +git clone https://git.private.coffee/privatecoffee/matrix-gptbot.git +cd matrix-gptbot + +# Create a config file +cp config.dist.ini config.ini +# Edit the config file to your needs + +# Optionally, create Pantalaimon config +cp pantalaimon.example.conf pantalaimon.conf +# Edit the Pantalaimon config file to your needs +# Don't forget to update config.ini to point to your Pantalaimon instance + +# Start the bot +docker-compose up -d +``` #### End-to-end encryption @@ -115,7 +172,12 @@ before merging. ## Running -The bot can be run with `python -m gptbot`. If required, activate a venv first. +The bot requires a configuration file to be present in the working directory. + +Copy the provided `config.dist.ini` to `config.ini` and edit it to your needs. + +The bot can then be run with `python -m gptbot`. If required, activate a venv +first. You may want to run the bot in a screen or tmux session, or use a process manager like systemd. The repository contains a sample systemd service file