My App
Production

Containers and Compose

ClayDiary runs in Docker containers.

Images

Built from our code

  • API: a Python image with only the locked production dependencies. The optional Discord bot reuses it with a different start command.
  • Frontend: built in two stages. Node builds the static files, and a small Nginx image serves them.
  • Documentation site: built in three stages (install, build, run) and runs as a non-root user.

In production, CI builds these images and publishes them to a registry, and the server pulls them.

Ready-made

  • PostgreSQL with TimescaleDB, Prometheus and Grafana, each with a pinned version.

Containers

One base Compose file holds what every environment shares: how each service is built or which image it uses, health checks, volumes and restart rules. It publishes no ports. Each environment adds a small file on top.

  • Development: base + development file. It publishes ports locally, mounts the source code and reloads the API on changes. The frontend and the documentation site run outside Docker.
  • Production: base + production file. It uses the registry images, publishes ports on localhost only and adds the frontend.
  • Documentation site: its own file only, independent of the base and of the application's pipeline.

Configuration

  • Secrets: they live in an env file on the server and reach the containers as environment variables, never inside an image.
  • Config files: they sit together in one config folder in the repository.
    • Nginx: how the frontend container serves the app. Baked into the frontend image.
    • Prometheus: what to collect. Mounted read-only.
    • Grafana: the data source and the dashboard. Mounted read-only.

Persistent data

  • The database and Prometheus keep their data on named volumes, so it survives replacing a container.
  • Grafana needs none, because its setup comes from files.

Reliability

  • Health checks: the database, API, frontend and documentation site each have one.
  • Start order: the API waits for a healthy database.
  • Restarts: containers restart automatically.

On this page