~/juanma
ES

Docker Lab

UNDER CONSTRUCTION

A hands-on containers lab, built module by module: a 6-service Docker Compose platform (Flask API, async worker, PostgreSQL and two Redis) across 4 segmented networks, with hardened non-root images, two CI/CD pipelines that scan with Trivy and publish to GHCR, and full observability — metrics and centralised logs. Built to justify every decision, with 9 ADRs recording the trade-offs and the bugs I hunted down.

Role
Design & build
Pattern
Containers · multi-service
Status
Under construction
Stack
Docker · CI/CD · o11y

System architecture

docker compose · 4 redes segmentadasobservabilidadDevelopergit pushGitHub Actionsbuild · Trivy scanGHCRimágenesAPI · Flask202 AcceptedRediscola · sesionesworkerescalablePostgreSQLAlembicPrometheus + Grafananode_exporter · cAdvisorFluent Bit → ES → Kibanalogs JSONpushpublishpull imageencolaconsumepersistescrapelogs

A developer pushes code; GitHub Actions builds the images, scans them with Trivy and publishes them to GHCR — only what passes the gate, and only from main. The runtime runs on Docker Compose across 4 segmented networks: the Flask API answers in milliseconds with 202 Accepted and enqueues work in Redis, a horizontally scalable worker consumes it, and PostgreSQL persists the data with Alembic migrations. Prometheus and Grafana scrape metrics from the host, the containers and the app, and logs flow as JSON through Fluent Bit to Elasticsearch and Kibana.

What it is & why I'm building it

Docker Lab is a progressive project: I build a small but realistic containerised system and evolve it stage by stage, so I can understand and defend every decision — from image layers to orchestration.

It runs six services on Docker Compose across four segmented networks — the data network has no route to the internet — and it is deliberately split by execution mode: an API that answers in milliseconds, a queue, and a worker that does the slow work.

Highlights

  • Six services, four networks — Flask API, async worker, PostgreSQL and two Redis (sessions and queue), with the data network isolated from the internet.
  • Hardened images — own images on python:3.13-slim, non-root user, patched base layer and a Trivy gate that blocks publishing.
  • Async by design — 202 Accepted + Redis queue + scalable worker, with idempotency, backoff retries and clean SIGTERM shutdown.
  • Two CI/CD pipelines — one per service: build → Trivy scan → publish to GHCR, tagged by commit SHA and with actions pinned by SHA.
  • Observability from day one — metrics in 3 layers (host, container and app) with Grafana dashboards as code, plus centralised JSON logs.

Key decisions

// why containers?

Reproducible everywhere

Compose describes the whole stack as code: the same environment on my laptop, in CI and in production. No «works on my machine».

// why harden images?

Small, safe images

Multi-stage builds keep images small; non-root users and vulnerability scans reduce the attack surface before anything ships.

// why a worker + queue?

Async by design

Splitting slow work into a worker behind a queue keeps the API responsive and lets each part scale independently.

// why split API and worker?

Split by execution mode

Not by domain: the API answers in milliseconds and returns 202 Accepted, while a worker without HTTP does the slow work. Each side scales on its own, and a duplicated message can't do duplicated work — idempotency is enforced by three chained mechanisms.

The build plan, stage by stage

Built module by module, each with explicit “done” criteria. Four of the six modules are complete; the rest is an honest roadmap, not a claim.

// built · modules M0–M3

  • Base stack: Flask API, worker, PostgreSQL and two Redis on Docker Compose
  • Hardened images: non-root, patched base layer, .dockerignore and Trivy gate
  • CI/CD per service (build → scan → GHCR), async worker and Alembic migrations
  • Observability: metrics in 3 layers and centralised JSON logs

// next · not started yet

  • Automated tests in the pipeline
  • Kubernetes and IaC — planned, not started

Stack & responsibilities

TechnologyLayerResponsibility
Docker · ComposeOrchestrationDefines and runs the 6-service stack across 4 segmented networks.
Python · FlaskAPIREST API and application logic.
PostgreSQLDataRelational persistence for the app.
Redis (x2)Cache · BrokerSeparate instances for sessions and for the job queue.
workerWorkerConsumes queued jobs for async processing.
GitHub ActionsCI/CDBuilds, scans with Trivy and publishes images to GHCR.
Trivy · non-rootSecurityHardened images and a scan gate; third-party actions pinned by SHA.
Prometheus · GrafanaMonitoringMetrics in 3 layers (node_exporter, cAdvisor, app) with dashboards as code.
Fluent Bit · Elasticsearch · KibanaLogsCentralised JSON logs correlated by request id.
Git · GitHubVersioningEverything versioned and documented, stage by stage.

Follow the build

The repo documents each module with its ADRs and how to reproduce it — or get in touch to talk it through.