docs: add Docker setup instructions to README.md

Introduced a new section in the README.md detailing how to run the server using Docker, including steps for building the image and running the container with both Docker Compose and the `docker run` command. This enhances the documentation for users looking to simplify dependency management.
This commit is contained in:
anonim 2025-04-24 15:03:11 +03:00
parent 02f326ce38
commit 3d3aef8360

View file

@ -168,6 +168,51 @@ Get your API credentials at [my.telegram.org/apps](https://my.telegram.org/apps)
---
## 🐳 Running with Docker
If you have Docker and Docker Compose installed, you can build and run the server in a container, simplifying dependency management.
### 1. Build the Image
From the project root directory, build the Docker image:
```bash
docker build -t telegram-mcp:latest .
```
### 2. Running the Container
You have two options:
**Option A: Using Docker Compose (Recommended for Local Use)**
This method uses the `docker-compose.yml` file and automatically reads your credentials from a `.env` file.
1. **Create `.env` File:** Ensure you have a `.env` file in the project root containing your `TELEGRAM_API_ID`, `TELEGRAM_API_HASH`, and `TELEGRAM_SESSION_STRING` (or `TELEGRAM_SESSION_NAME`). Use `.env.example` as a template.
2. **Run Compose:**
```bash
docker compose up --build
```
* Use `docker compose up -d` to run in detached mode (background).
* Press `Ctrl+C` to stop the server.
**Option B: Using `docker run`**
You can run the container directly, passing credentials as environment variables.
```bash
docker run -it --rm \
-e TELEGRAM_API_ID="YOUR_API_ID" \
-e TELEGRAM_API_HASH="YOUR_API_HASH" \
-e TELEGRAM_SESSION_STRING="YOUR_SESSION_STRING" \
telegram-mcp:latest
```
* Replace placeholders with your actual credentials.
* Use `-e TELEGRAM_SESSION_NAME=your_session_file_name` instead of `TELEGRAM_SESSION_STRING` if you prefer file-based sessions (requires volume mounting, see `docker-compose.yml` for an example).
* The `-it` flags are crucial for interacting with the server.
---
## ⚙️ Configuration for Claude & Cursor
### MCP Configuration