feat: add traefik tcp load balancer

This commit is contained in:
Alfredo Di Stasio
2026-06-30 09:50:18 +02:00
parent 786fa78ebd
commit 7dfc23d69e
13 changed files with 393 additions and 129 deletions
+51 -61
View File
@@ -1,73 +1,63 @@
# codex-bootstrap
# Traefik TCP Load Balancer
A repository template for AI-assisted development with Codex.
Docker Compose deployment for Traefik used as a TCP load balancer with TLS passthrough.
This template defines a repeatable workflow for using Codex as an autonomous coding agent that can create branches, modify code, run Docker-based tests, update documentation, write ADRs, and commit changes using Conventional Commits.
## What it does
## Purpose
- publishes `443/tcp` on the Docker host;
- forwards TCP TLS traffic to backend IP addresses and ports;
- leaves SSL certificates and private keys on the backends;
- stores Traefik configuration in the host `./config` directory;
- uses the Traefik file provider, without mounting the Docker socket.
Use this template to bootstrap repositories where Codex must operate with clear rules, minimal changes, pragmatic TDD, security guardrails, and explicit documentation requirements.
## Configuration
## Repository structure
Edit backend targets in `config/dynamic/tcp-services.yml`:
```text
.
├── AGENTS.md
├── README.md
├── .codex/
│ ├── project.md
│ ├── workflow.md
│ ├── security.md
│ ├── quality.md
│ ├── orchestration.md
│ ├── prompts/
│ │ ├── task.md
│ │ ├── bugfix.md
│ │ ├── refactor.md
│ │ ├── security-review.md
│ │ └── documentation.md
│ ├── agents/
│ │ ├── architect.md
│ │ ├── developer.md
│ │ ├── reviewer.md
│ │ ├── security-reviewer.md
│ │ ├── test-engineer.md
│ │ └── documentation-writer.md
│ └── profiles/
│ ├── docker.md
│ ├── ansible.md
│ └── python.md
└── docs/
├── adr/
│ └── 0000-template.md
├── architecture.md
├── deployment.md
├── operations.md
├── security.md
├── testing.md
└── runbook.md
```yaml
tcp:
services:
ssl-backends:
loadBalancer:
servers:
- address: "192.0.2.10:443"
- address: "192.0.2.11:443"
```
## How to use
The example addresses use the documentation-only `192.0.2.0/24` range. Replace them with the real backend IP addresses and ports before deploying. If a backend listens on the Docker host itself, use `host.docker.internal:PORT`.
1. Copy this template into a new or existing repository.
2. Edit `.codex/project.md` and configure:
- project mode;
- enabled profiles;
- Docker-based test command;
- branch naming rules if needed.
3. Add project-specific details to the documentation under `docs/`.
4. When asking Codex to work on a task, use one of the prompt templates under `.codex/prompts/`.
## Run
## Core rules
Validate the Compose file:
Codex must:
```bash
docker compose config
```
- start work from `develop`;
- create a dedicated `feature/`, `fix/`, or `hotfix/` branch;
- use pragmatic TDD;
- keep changes minimal and focused;
- run the configured Docker-based test command before completion;
- update documentation and ADRs when needed;
- produce a final report with summary, tests, risks, and rollback notes;
- commit using Conventional Commits.
Start Traefik:
```bash
docker compose up -d
```
View logs:
```bash
docker compose logs -f traefik
```
Stop the service:
```bash
docker compose down
```
## Documentation
- Architecture: `docs/architecture.md`
- Deployment: `docs/deployment.md`
- Operations: `docs/operations.md`
- Security: `docs/security.md`
- Testing: `docs/testing.md`
- Runbook: `docs/runbook.md`
- ADR: `docs/adr/0001-traefik-tcp-tls-passthrough.md`