|
43 | 43 |
|
44 | 44 | --- |
45 | 45 |
|
46 | | -# Installing |
| 46 | +# Installing (No Docker) |
47 | 47 |
|
48 | 48 | 1. **Clone the repository with:** |
49 | 49 |
|
|
91 | 91 |
|
92 | 92 | --- |
93 | 93 |
|
| 94 | +## **Dockerized Install Instructions** |
| 95 | + |
| 96 | +### **Prerequisites** |
| 97 | +1. **Docker** must be installed on your machine. |
| 98 | + - If not installed, you can download and install it from [Docker's official site](https://www.docker.com/get-started). |
| 99 | + |
| 100 | +2. **Telegram Bot API Key** and **OpenAI API Key**: |
| 101 | + - You will need a valid Telegram Bot API key. You can get one by creating a bot with [BotFather](https://core.telegram.org/bots#botfather). |
| 102 | + - You will also need an OpenAI API key. If you don't have one, you can generate it from the [OpenAI API page](https://beta.openai.com/signup/). |
| 103 | + |
| 104 | +### **Step 1: Clone the Repository** |
| 105 | + |
| 106 | +First, clone the repository from GitHub: |
| 107 | + |
| 108 | +```bash |
| 109 | +git clone https://github.com/FlyingFathead/TelegramBot-OpenAI-API.git |
| 110 | +cd TelegramBot-OpenAI-API |
| 111 | +``` |
| 112 | + |
| 113 | +### **Step 2: Run the Setup Script** |
| 114 | + |
| 115 | +This project includes a setup script that will guide you through entering your API keys and generating a `.env` file. |
| 116 | + |
| 117 | +Run the script: |
| 118 | + |
| 119 | +```bash |
| 120 | +./docker_setup.sh |
| 121 | +``` |
| 122 | + |
| 123 | +Follow the instructions provided by the script. It will ask for your OpenAI API key and Telegram Bot API key, validate them, and create a `.env` file with your credentials. |
| 124 | + |
| 125 | +### **Step 3: Build the Docker Image** |
| 126 | + |
| 127 | +Once your `.env` file has been created, you need to build the Docker image. |
| 128 | + |
| 129 | +Run the following command to build the Docker image: |
| 130 | + |
| 131 | +```bash |
| 132 | +sudo docker build -t telegrambot-openai-api . |
| 133 | +``` |
| 134 | + |
| 135 | +This will build the image locally based on the `Dockerfile` in the repository. |
| 136 | + |
| 137 | +### **Step 4: Run the Docker Container** |
| 138 | + |
| 139 | +After the image is successfully built, you can start the bot in a Docker container. |
| 140 | + |
| 141 | +Run the container with the following command: |
| 142 | + |
| 143 | +```bash |
| 144 | +sudo docker run --env-file .env -d telegrambot-openai-api |
| 145 | +``` |
| 146 | + |
| 147 | +- The `-d` flag runs the container in detached mode (in the background). |
| 148 | +- The `--env-file .env` flag injects your API keys into the container. |
| 149 | + |
| 150 | +### **Step 5: Check the Running Container** |
| 151 | + |
| 152 | +You can check if the container is running by using: |
| 153 | + |
| 154 | +```bash |
| 155 | +sudo docker ps |
| 156 | +``` |
| 157 | + |
| 158 | +This will list all running containers. If your bot is running correctly, it should appear in the list. |
| 159 | + |
| 160 | +### **Step 6: Stopping the Container** |
| 161 | + |
| 162 | +If you need to stop the bot, you can do so by running: |
| 163 | + |
| 164 | +```bash |
| 165 | +sudo docker stop <container_id> |
| 166 | +``` |
| 167 | + |
| 168 | +Replace `<container_id>` with the actual container ID, which you can obtain from the `docker ps` output. |
| 169 | + |
| 170 | +### **Additional Steps (Optional)** |
| 171 | + |
| 172 | +- **Logs**: If you need to view the bot’s logs to troubleshoot any issues, you can use: |
| 173 | + |
| 174 | + ```bash |
| 175 | + sudo docker logs <container_id> |
| 176 | + ``` |
| 177 | + |
| 178 | +- **Restart the Container**: If you stop the container and want to start it again, you can either run the `docker run` command again or restart the existing container with: |
| 179 | + |
| 180 | + ```bash |
| 181 | + sudo docker start <container_id> |
| 182 | + ``` |
| 183 | + |
| 184 | +### **Updating the Bot** |
| 185 | + |
| 186 | +If the repository receives updates and you want to apply them, follow these steps: |
| 187 | + |
| 188 | +1. Pull the latest changes from GitHub: |
| 189 | + ```bash |
| 190 | + git pull origin main |
| 191 | + ``` |
| 192 | + |
| 193 | +2. Rebuild the Docker image: |
| 194 | + ```bash |
| 195 | + sudo docker build -t telegrambot-openai-api . |
| 196 | + ``` |
| 197 | + |
| 198 | +3. Stop the currently running container: |
| 199 | + ```bash |
| 200 | + sudo docker stop <container_id> |
| 201 | + ``` |
| 202 | + |
| 203 | +4. Start a new container using the updated image: |
| 204 | + ```bash |
| 205 | + sudo docker run --env-file .env -d telegrambot-openai-api |
| 206 | + ``` |
| 207 | + |
| 208 | +You should now have the TelegramBot-OpenAI-API running in a Docker container, fully connected to both Telegram and OpenAI. Enjoy your bot! |
| 209 | + |
| 210 | +If you run into any issues, consult the logs or reach out on the repository's [Issues page](https://github.com/FlyingFathead/TelegramBot-OpenAI-API/issues). |
| 211 | + |
| 212 | +--- |
| 213 | + |
94 | 214 | # Updating |
95 | 215 |
|
96 | 216 | - Use the `configmerger.py` to update old configuration files into a newer version's `config.ini`. You can do this by saving a copy of your existing config to i.e. a file named `myconfig.txt` and including in it the lines you want to keep for the newer version. |
|
106 | 226 | --- |
107 | 227 |
|
108 | 228 | # Changelog |
| 229 | +- v0.7502 - added `docker_setup.sh` for easier Docker-based deployment |
109 | 230 | - v0.7501 - `Dockerfile` and better error catching when receiving `401 Unauthorized` |
110 | 231 | - v0.75 **Major refactoring** _(5. Oct 2024)_ 👀💦🌀 |
111 | 232 | - entire project has been tidied up and a lot of bugs fixed while at it |
|
0 commit comments