48-Hour Field Notes: The Port the Repo Never Opened
Описание и применение
Создана проверка, которая гарантирует, что сгенерированные Docker‑файлы и docker‑compose соответствуют реальной конфигурации приложения, предотвращая ошибки порта при деплое.
Задача
Generated Docker and compose files introduced a port mismatch that caused runtime failures while tests passed, leading to a silent deployment bug.
Результат
The checker prevented a silent deployment bug by enforcing consistency between generated ops files and the repository’s actual runtime configuration.
Рабочий процесс
- 1. Identify port mismatch between generated Dockerfile/compose and application defaults.
- 2. Create a runtime contract JSON specifying expected http_bind_port, host, probe_url, forbidden_ports, and postgres_transport details.
- 3. Write a Python script that scans Dockerfiles, compose files, and scripts for port declarations using regex.
- 4. Compare found ports against the contract; flag any mismatches or forbidden ports.
- 5. Run the checker before CI builds to fail the build if inconsistencies are detected.
- 6. Adjust generated files or contract as needed to resolve mismatches.
- 7. Re-run CI to confirm build passes and runtime matches contract.
Доказательства
I stopped asking for a better patch and wrote a file the patch had to lose against. The contract is boring on purpose.
Hour 18 I wired a checker that walks generated compose files, Dockerfiles, and shell probes, then fails if a literal host, port, or scheme disagrees with the contract.
- Дата записи: 2026-09-15T04:45:47.197Z