Skip to content

Deploying containers over SSH, without a registry ​

Catapult has always deployed by copying releases to a server over SSH and switching a current symlink. Many teams also ship their applications as container images, but the usual path to production adds pieces: a registry, credentials on every server, an orchestrator, or a CI job that pushes and pulls.

For a single server or a handful of them, that is often more than needed. Catapult now has three experimental recipes that keep the SSH model and apply it to images: build on your machine, stream the image to each server, start the containers, check them, and roll back to the exact previous images if anything goes wrong.

Three recipes, one image pipeline ​

RecipeUse it forEngine
composeA stack described in a Compose file, databases includedDocker or Podman
containerA few processes sharing one image: web, workers, schedulerDocker or Podman
quadletContainers managed as systemd services with Podman QuadletPodman

The Compose walkthrough and Quadlet walkthrough each deploy a small HTTP service from a complete example.

They share the same image steps:

  1. The image is built locally once per deployment, for the architecture of the servers, and tagged with the release name.
  2. It is streamed to each server with save | gzip | ssh | load, without writing an archive and without a registry. When the image did not change since the current release, the server only adds the new tag.
  3. An optional migration runs in a one-off container of the new image, before publication. A failed migration stops the deployment while the previous release keeps running.
  4. The containers start from the new image, and Catapult waits until they run and are healthy.

Each release keeps a release.json manifest with the image IDs and how the containers were started, but never the values of environment variables. Secrets stay in a shared .env passed as an env file.

A quick look at container ​

The container recipe needs no Compose file. Services are declared in the deploy config:

typescript
// deploy.ts
import { defineConfig, set } from '@catapultjs/deploy'
import '@catapultjs/deploy/recipes/container'

set('container_engine', 'podman')
set('shared_files', ['.env'])
set('container_services', {
  web: {
    command: ['node', 'bin/server.js'],
    init: true,
    env_file: ['.env'],
    ports: ['127.0.0.1:3333:3333'],
  },
  worker: {
    command: ['node', 'ace', 'queue:work'],
    init: true,
    healthcheck: false,
    env_file: ['.env'],
  },
})
set('container_migrate', { service: 'web', command: ['node', 'ace', 'migration:run', '--force'] })

export default defineConfig({
  hosts: [
    {
      name: 'production',
      ssh: 'deploy@example.com',
      deployPath: '/srv/myapp',
      healthcheck: { url: 'http://127.0.0.1:3333/health', retries: 10 },
    },
  ],
})

Run npx cata deploy:setup once, put the production .env in shared/.env, then npx cata deploy. Services can also set resource limits (memory, cpus), extra networks, a healthcheck defined in the config, or raw engine options.

With compose, your Compose files stay untouched: Catapult generates a compose.catapult.yml override that pins the release image. With quadlet, you write .container files with placeholders such as {{image}}, and systemd starts and supervises the containers, at boot too.

Catching crash loops ​

A container with restart: always that crashes on startup can look "running" most of the time. Catapult watches the containers for a few seconds after they start: a container that exits, becomes unhealthy, or restarts repeatedly while waiting fails the deployment, and the automatic rollback restores the previous release.

Rollback to the exact images ​

npx cata rollback switches current back and recreates the containers recorded by the restored release: same image, same command, same env files. If the target image is missing, registry mode can pull it again by digest before the switch. With SSH transfer, a missing target image blocks the rollback. As with every Catapult deployment, data and migrations are not reversed.

Zero downtime with Caddy ​

Replacing a container in place leaves a short gap on its port. For web services behind Caddy, the container recipe offers a blue_green mode:

typescript
web: {
  command: ['node', 'bin/server.js'],
  init: true,
  env_file: ['.env'],
  blue_green: { ports: [3001, 3002], container_port: 3333, health_path: '/health' },
}

The new release starts on the idle port, gets checked directly, then Catapult rewrites the Caddy upstream and reloads Caddy. Requests in flight finish on the previous container, which stops after a drain delay. If the deployment fails before container:retire, rollback can point Caddy back to the still-running previous container. A later rollback starts the restored release in the idle slot before switching traffic.

When SSH streaming is not enough ​

Streaming the image is the default because it needs nothing more than SSH. Two options cover larger setups:

  • Registry transfer: push the image once to a registry such as GitHub Container Registry, and let each server pull it by digest. Credentials of the servers come from local environment variables and never stay on them.
  • Build on the servers: with container_build.location: 'remote', the build context is synchronized with rsync and each server builds the image natively, with its own layer cache.

Experimental, and feedback welcome ​

These recipes are experimental: options and defaults may still change in a minor release. They have been tested with Docker and Podman, rootless and rootful, on Ubuntu and Fedora. If you try them, open an issue with what works and what does not.

Containers are not required to use Catapult, and the classic release model stays the default. They are one more way to ship, with the same commands: cata deploy, cata rollback, cata status.