My App
Production

Server and Network

ClayDiary runs on one VPS at Contabo with Ubuntu. The server started empty, so everything it needs was installed by hand.

Server setup

  • Installed software:
    • Docker: the engine and the Compose plugin, to run the containers.
    • Git: to keep the repository on the server up to date.
    • Caddy: the web server in front of the application.
    • Tailscale: private access to the database.
  • Repository: cloned onto the server with a read-only deploy key, so the server can pull code but never push.
  • Login: by SSH key only, no password.
  • Application secrets: kept in an env file on the server.

Connections

ConnectionHowWhat for
Laptop → serverSSH, personal keyAdministration and tunnels to private services
Server → GitHub repositorySSH, read-only deploy keyPulling the repository files
GitHub Actions → serverSSH, key stored in GitHub secretsRunning the deploys
Server → container registryHTTPSPulling the images
Laptop → databaseTailscaleDatabase access from pgAdmin

Caddy

Caddy is the web server in front of the application. It runs on the server itself, not in a container.

  • Domain: a free DuckDNS domain points at the server.
  • HTTPS: Caddy obtains and renews the certificates automatically, and redirects HTTP to HTTPS.
  • Routing: Caddy sends each request to a container by hostname.
    • Application host: requests to /api go to the backend, and everything else goes to the frontend.
    • Grafana host: Grafana.
    • Documentation host: the documentation site, with the root address redirecting to its documentation pages.

Network exposure

  • The Contabo firewall lets only SSH, HTTP and HTTPS in.
  • Every container port is bound to localhost, so Caddy is the only way in from the internet.
  • Caddy exposes three services: the application, Grafana (behind its login) and the documentation site.
  • PostgreSQL and Prometheus are not exposed. The database is reached from a laptop through Tailscale.

On this page