Skip to content

Commit 98d0efd

Browse files
committed
chore(repo): add Claude guidance file and ignore local Claude/worktrees files
Adds CLAUDE.md with project overview, commands, architecture, configuration, and versioning notes, and updates .gitignore/.dockerignore to exclude .worktrees and local Claude settings.
1 parent 7829bc0 commit 98d0efd

3 files changed

Lines changed: 74 additions & 0 deletions

File tree

.dockerignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,3 +53,4 @@ venv.bak/
5353

5454
# Misc
5555
.history
56+
.worktrees

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,3 +50,7 @@ venv.bak/
5050
# Misc
5151
.history
5252
/test
53+
54+
# Claude
55+
/.claude/settings.local.json
56+
.worktrees

CLAUDE.md

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
# CLAUDE.md
2+
3+
This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
4+
5+
## Project Overview
6+
7+
**auto_docker_proxy** (aka Traefik Network Connector) is a Python daemon that dynamically connects/disconnects the Traefik reverse proxy to Docker container networks. It monitors Docker events in real-time and manages network connections for containers labeled `traefik.enable=true`, eliminating the need for a shared Docker network across all stacks.
8+
9+
## Build & Run Commands
10+
11+
```bash
12+
# Docker build
13+
docker build --build-arg VERSION=$(cat VERSION) -t obeoneorg/traefik_network_connector .
14+
15+
# Docker Compose (dev/demo with Traefik included)
16+
VERSION=$(cat VERSION) docker compose up --build
17+
18+
# Local run (requires Python 3.6+ and Docker socket access)
19+
pip install -r requirements.txt
20+
python main.py
21+
python main.py --config=/path/to/config.yaml
22+
python main.py --traefik.containername=mytraefik --loglevel.application=DEBUG
23+
24+
# Tests (pytest)
25+
pytest tests/
26+
pytest tests/unit/
27+
pytest tests/integration/
28+
29+
# Version bump + tag
30+
./scripts/bump-version.sh [major|minor|patch]
31+
```
32+
33+
## Architecture
34+
35+
The entire application is two Python files:
36+
37+
- **`main.py`** — All runtime logic: Docker client creation, event monitoring loop, network connect/disconnect logic, container cache management.
38+
- **`config.py`** — Configuration loading with three-layer priority: `config.yaml` defaults < environment variables < CLI arguments. Uses `NamedTuple` types (`Config`, `DockerConfig`, `TraefikConfig`, etc.).
39+
40+
### Core Flow
41+
42+
1. **Startup**: Creates Docker client, scans all running containers, connects Traefik to networks of containers with `traefik.enable=true` label.
43+
2. **Event loop** (`monitor_events()`): Listens to Docker container events:
44+
- `start`: If Traefik itself starts → reconnect to all relevant networks. If labeled container starts → connect Traefik to its network.
45+
- `stop`/`die`: If labeled container stops → disconnect Traefik from its network only if no other labeled containers remain on it.
46+
3. **Container cache** (`container_cache` dict): Stores container objects by ID so they can be referenced on `stop`/`die` events when the container API may no longer return them.
47+
48+
### Key Labels
49+
50+
- `traefik.enable` (regex-matched via `traefik.monitoredLabel` config) — triggers network connection
51+
- `traefik.docker.network` — specifies which network(s) Traefik should connect to for a container
52+
53+
## Configuration
54+
55+
Three-layer priority (lowest to highest): `config.yaml` → environment variables → CLI arguments.
56+
57+
Environment variables use `_` as separator (e.g., `DOCKER_HOST`, `TRAEFIK_CONTAINERNAME`). CLI arguments use `.` separator with `--` prefix (e.g., `--docker.host`, `--traefik.containername`).
58+
59+
## Versioning & CI/CD
60+
61+
- Version tracked in `VERSION` file (SemVer format)
62+
- `scripts/bump-version.sh` increments version, commits, and creates git tag
63+
- `scripts/generate-tags.sh` generates Docker tags from a SemVer git tag
64+
- CI builds multi-platform images (`amd64`, `arm64`, `i386`, `arm/v7`) and pushes to both GHCR and Docker Hub under two names: `auto_docker_proxy` and `traefik_network_connector`
65+
- Releases are triggered by pushing `vX.Y.Z` tags
66+
67+
## Dependencies
68+
69+
Minimal: `docker` (Python SDK), `coloredlogs`, `PyYAML` — see `requirements.txt`.

0 commit comments

Comments
 (0)