diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 00000000..e13e81ff --- /dev/null +++ b/Dockerfile @@ -0,0 +1,28 @@ +# Use the official Python image as the base image +FROM python:3.10.8 + +# Create a user named appuser +RUN useradd -m appuser + +# Switch to the appuser user +USER appuser + +WORKDIR /home/appuser/ + +ENV PATH="/home/appuser/.local/bin:$PATH" + +# Install pipenv +RUN pip install --user pipenv + +# Pull the repository from Github +RUN git clone --depth=1 https://github.com/n3d1117/chatgpt-telegram-bot.git app + +# Enter the repository directory +WORKDIR /home/appuser/app + +# Install the dependencies specified in the Pipfile in the repository +RUN pipenv install --deploy + +ENTRYPOINT ["python", "-m", "pipenv", "run"] +# Run the main.py file +CMD ["python", "main.py"] diff --git a/README.md b/README.md index edce8237..b66844eb 100644 --- a/README.md +++ b/README.md @@ -14,14 +14,13 @@ A [Telegram bot](https://core.telegram.org/bots/api) that integrates with OpenAI - [x] Can reset conversation thread with the `/reset` command - [x] Typing indicator while generating a response - [x] Access can be restricted by specifying a list of allowed users +- [x] Docker support ## Additional Features - help needed! - [ ] Multi-chat support - Idea: cache different instances of `ChatGPT3Bot`, one for every chat id (maybe even persist them), so that every user has their own private conversation - [ ] Support group chats - Allow the bot to be used in group chats with specific commands -- [ ] Docker support - - With `Dockerfile` and `docker-compose.yml`. See [pull/2](https://github.com/n3d1117/chatgpt-telegram-bot/pull/2) for a start - [ ] Advanced commands - With premade ad-hoc prompts - [ ] Token based authentication @@ -37,6 +36,7 @@ PRs are always welcome! ## Getting started ### Installing +#### From Source 1. Clone the repository and navigate to the project directory: ```bash @@ -54,6 +54,13 @@ pipenv install pipenv shell ``` +#### Docker Compose + +```bash +wget https://raw.githubusercontent.com/n3d1117/chatgpt-telegram-bot/main/docker-compose.yml +docker-compose up -d +``` + ### Configuration Customize the configuration by copying `.env.example` and renaming it to `.env`, then editing the settings as desired: ```bash diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 00000000..de85f18c --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,7 @@ +version: '3' +services: + chatgpt: + image: sheepgreen/chatgpt + volumes: + - ./.env:/home/appuser/app/.env + restart: always