iac/nixos/hosts/asxpio-ops/apps.nix
Sergei Poljanski fa46d26f89
nixos: app stacks on Podman, unchanged
The apps keep deploying themselves: their CI copies a compose file and
a .env and runs docker compose as user deploy. `docker` is now the real
Docker CLI against rootful Podman's socket, so compose, inspect and
logs behave as before and every user sees the same containers.

Their compose files still expect the storage stack's network and the
hosts postgres and garage. On ops every container resolves those two
names to the host, where the native services run, and an empty storage
network exists, so nothing in the app repositories has to change for
the move itself.

Tried on the rehearsal pair with the real asxpio and datacenterbingo
images on the restored database and Garage (mail and IndexNow
disabled): both serve through Traefik, and a local compose build works.

One thing does need the app repositories: Podman ignores the
HEALTHCHECK of OCI-format images, which is what the CI builds, so the
deploy's wait for "healthy" would time out. Declaring the healthcheck
in each compose file fixes it, also under Docker; see MIGRATION.md.

ops-data.sh now also moves the monitoring history, Traefik's
certificates and the app directories, and pulls the images again.

Assisted-by: Claude:opus-5-5
2026-11-17 05:11:17 +04:00

38 lines
1.5 KiB
Nix

# The app stacks (asxpio, datacenterbingo, blog, czsk, vhpbot) deploy
# themselves from their own repositories: CI copies a compose file and a
# .env to /opt/<app> and runs `docker compose up -d` as user deploy.
#
# Their compose files still expect the Docker-era storage stack: a
# network named "storage" and the hosts "postgres" and "garage" on it.
# Postgres and Garage are native services now, so every container on
# this host resolves those two names to the host, and the network exists
# empty. Nothing in the app repositories has to change for the move;
# dropping the storage network from their compose files is a later
# clean-up.
{ config, pkgs, ... }:
let
hosts = pkgs.writeText "container-hosts" ''
10.10.0.10 postgres garage
'';
in
{
virtualisation.containers.containersConf.settings.containers.base_hosts_file = "${hosts}";
# The API service (the socket the Docker CLI and Traefik use) reads it
# at start only
systemd.services.podman.restartTriggers = [ hosts ];
# `docker compose up --build` (vhpbot-prod builds on the host) starts
# BuildKit in a privileged container
asxpio.security.containers."buildx_buildkit_.*" = [ "privileged" ];
systemd.services.podman-network-storage = {
description = "Podman network storage (empty; see apps.nix)";
wantedBy = [ "multi-user.target" ];
path = [ config.virtualisation.podman.package ];
serviceConfig = {
Type = "oneshot";
RemainAfterExit = true;
};
script = "podman network exists storage || podman network create storage";
};
}