|
1 | 1 | # DB-TimetableAPI-MCPServer |
2 | 2 |
|
3 | 3 | [](https://github.com/abeckDev/DB-TimetableAPI-MCPServer/actions/workflows/dotnet-ci.yml) |
| 4 | +[](https://github.com/abeckDev/DB-TimetableAPI-MCPServer/actions/workflows/docker-publish.yml) |
4 | 5 | [](https://opensource.org/licenses/MIT) |
5 | 6 | [](https://codecov.io/github/abeckDev/DB-TimetableAPI-MCPServer) |
6 | 7 |
|
@@ -187,6 +188,90 @@ dotnet build |
187 | 188 |
|
188 | 189 | The project should build successfully. If you encounter any issues, ensure you have .NET 9.0 SDK installed. |
189 | 190 |
|
| 191 | +### Using Docker (Recommended for Production) |
| 192 | + |
| 193 | +The easiest way to run the MCP server is using Docker. Pre-built images are automatically published to the GitHub Container Registry. |
| 194 | + |
| 195 | +#### Pull and Run the Latest Image |
| 196 | + |
| 197 | +```bash |
| 198 | +# Pull the latest image from GitHub Container Registry |
| 199 | +docker pull ghcr.io/abeckdev/db-timetableapi-mcpserver:latest |
| 200 | + |
| 201 | +# Run the container with your API credentials |
| 202 | +docker run -d \ |
| 203 | + --name db-timetable-mcp \ |
| 204 | + -p 3001:3001 \ |
| 205 | + -e DeutscheBahnApi__ClientId="your-actual-client-id" \ |
| 206 | + -e DeutscheBahnApi__ApiKey="your-actual-api-key" \ |
| 207 | + -e DeutscheBahnApi__BaseUrl="https://apis.deutschebahn.com/db-api-marketplace/apis/timetables/v1/" \ |
| 208 | + ghcr.io/abeckdev/db-timetableapi-mcpserver:latest |
| 209 | + |
| 210 | +# Check if the container is running |
| 211 | +docker ps |
| 212 | + |
| 213 | +# View logs |
| 214 | +docker logs db-timetable-mcp |
| 215 | +``` |
| 216 | + |
| 217 | +The MCP server will be accessible at `http://localhost:3001/mcp`. |
| 218 | + |
| 219 | +#### Build Your Own Docker Image |
| 220 | + |
| 221 | +If you prefer to build the Docker image locally: |
| 222 | + |
| 223 | +```bash |
| 224 | +# Build the image |
| 225 | +docker build -t db-timetableapi-mcpserver:local . |
| 226 | + |
| 227 | +# Run the container |
| 228 | +docker run -d \ |
| 229 | + --name db-timetable-mcp \ |
| 230 | + -p 3001:3001 \ |
| 231 | + -e DeutscheBahnApi__ClientId="your-actual-client-id" \ |
| 232 | + -e DeutscheBahnApi__ApiKey="your-actual-api-key" \ |
| 233 | + -e DeutscheBahnApi__BaseUrl="https://apis.deutschebahn.com/db-api-marketplace/apis/timetables/v1/" \ |
| 234 | + db-timetableapi-mcpserver:local |
| 235 | +``` |
| 236 | + |
| 237 | +#### Docker Compose |
| 238 | + |
| 239 | +You can also use Docker Compose for easier management. Create a `docker-compose.yml` file: |
| 240 | + |
| 241 | +```yaml |
| 242 | +services: |
| 243 | + mcp-server: |
| 244 | + image: ghcr.io/abeckdev/db-timetableapi-mcpserver:latest |
| 245 | + container_name: db-timetable-mcp |
| 246 | + ports: |
| 247 | + - "3001:3001" |
| 248 | + environment: |
| 249 | + - DeutscheBahnApi__ClientId=your-actual-client-id |
| 250 | + - DeutscheBahnApi__ApiKey=your-actual-api-key |
| 251 | + - DeutscheBahnApi__BaseUrl=https://apis.deutschebahn.com/db-api-marketplace/apis/timetables/v1/ |
| 252 | + restart: unless-stopped |
| 253 | +``` |
| 254 | +
|
| 255 | +Then run: |
| 256 | +
|
| 257 | +```bash |
| 258 | +docker compose up -d |
| 259 | +``` |
| 260 | + |
| 261 | +#### Docker Image Tags |
| 262 | + |
| 263 | +Images are tagged with multiple identifiers for flexibility: |
| 264 | + |
| 265 | +- `latest` - The most recent build from the main branch |
| 266 | +- `main` - Same as latest, tracks the main branch |
| 267 | +- `main-<sha>` - Specific commit SHA from the main branch (e.g., `main-abc1234`) |
| 268 | + |
| 269 | +Example pulling a specific version: |
| 270 | + |
| 271 | +```bash |
| 272 | +docker pull ghcr.io/abeckdev/db-timetableapi-mcpserver:main-a1b2c3d |
| 273 | +``` |
| 274 | + |
190 | 275 | --- |
191 | 276 |
|
192 | 277 | ## ⚙️ Configuration |
@@ -680,9 +765,25 @@ All pull requests automatically run: |
680 | 765 | - ✅ All unit tests |
681 | 766 | - ✅ Code coverage analysis |
682 | 767 | - ✅ Coverage threshold checks (70% minimum) |
| 768 | +- ✅ Docker image build verification |
683 | 769 |
|
684 | 770 | Coverage reports are available as workflow artifacts. |
685 | 771 |
|
| 772 | +### Continuous Deployment |
| 773 | + |
| 774 | +When changes are pushed to the `main` branch: |
| 775 | +- ✅ Docker images are automatically built |
| 776 | +- ✅ Images are tagged with multiple identifiers (latest, main, commit SHA) |
| 777 | +- ✅ Images are published to GitHub Container Registry (ghcr.io) |
| 778 | +- ✅ Images are publicly accessible at `ghcr.io/abeckdev/db-timetableapi-mcpserver` |
| 779 | + |
| 780 | +The Docker image includes: |
| 781 | +- Multi-stage build for optimized size |
| 782 | +- .NET 9.0 runtime on Debian Bookworm (slim variant) |
| 783 | +- Non-root user for enhanced security |
| 784 | +- Health check endpoint |
| 785 | +- Proper port exposure (3001) |
| 786 | + |
686 | 787 | --- |
687 | 788 |
|
688 | 789 | ## 🤝 Contributing |
|
0 commit comments