Skip to content

Run in a container

The image ghcr.io/bastionxp/bastionxp-ca is a static binary on a distroless base. It runs bxp serve --config /etc/bastionxp-ca/bastionxp-ca.yaml as a non-root user (uid 65532), with its data in the volume /var/lib/bastionxp-ca.

Set data_dir: /var/lib/bastionxp-ca in the configuration.

Docker

# Once: create the CA. It asks for the root passphrase, so -it. The root
# key goes to ./offline on the host, not into the volume.
docker run -it --rm -v bastionxp-ca-data:/var/lib/bastionxp-ca -v ./offline:/offline \
    -v ./bastionxp-ca.yaml:/etc/bastionxp-ca/bastionxp-ca.yaml:ro \
    ghcr.io/bastionxp/bastionxp-ca init --config /etc/bastionxp-ca/bastionxp-ca.yaml --root-key-out /offline/root.key

# Then run the server.
docker run -d --name bastionxp-ca -p 8443:8443 -v bastionxp-ca-data:/var/lib/bastionxp-ca \
    -v ./bastionxp-ca.yaml:/etc/bastionxp-ca/bastionxp-ca.yaml:ro ghcr.io/bastionxp/bastionxp-ca
  • ./offline must be writable by the container's user (uid 65532). Move root.key off the host afterwards.
  • server.names must include the name clients use to reach the published port.

Docker Compose

compose.yaml
services:
  bastionxp-ca:
    image: ghcr.io/bastionxp/bastionxp-ca
    restart: unless-stopped
    ports:
      - "8443:8443"
      - "8080:8080"            # server.public_address, if used
    volumes:
      - bastionxp-ca-data:/var/lib/bastionxp-ca
      - ./bastionxp-ca.yaml:/etc/bastionxp-ca/bastionxp-ca.yaml:ro
    environment:
      BXP_LOG_FORMAT: json
      BXP_KEY_PASSPHRASE_FILE: /run/secrets/bastionxp-ca-key-passphrase
    secrets:
      - bastionxp-ca-key-passphrase

volumes:
  bastionxp-ca-data:

secrets:
  bastionxp-ca-key-passphrase:
    file: ./bastionxp-ca-key-passphrase.txt

Encrypted server keys

Give the passphrase as a secret file and point BXP_KEY_PASSPHRASE_FILE at it, as above. Docker and Kubernetes secrets are files. Avoid passing the passphrase itself in an environment variable: docker inspect shows a container's environment.

Metrics in a container

A container's 127.0.0.1 is not reachable even from the host. Bind metrics to 0.0.0.0:9100 inside the container and publish the port to an internal address only:

docker run ... -p 10.0.0.5:9100:9100 ghcr.io/bastionxp/bastionxp-ca

See Monitoring.

Running other commands

Run the CA-side commands in the same container, so they see the same volume and configuration. The image is distroless: it has the bxp binary and nothing else, no shell.

docker exec bxp /usr/local/bin/bxp token --config /etc/bastionxp-ca/bastionxp-ca.yaml --profile tls-server --name web.example.com
docker exec bxp /usr/local/bin/bxp list certificates --config /etc/bastionxp-ca/bastionxp-ca.yaml
docker exec bxp /usr/local/bin/bxp doctor --config /etc/bastionxp-ca/bastionxp-ca.yaml

Kubernetes notes

  • Use a StatefulSet with one replica and a PersistentVolumeClaim for /var/lib/bastionxp-ca. BastionXP CA uses one SQLite file: run one replica.
  • Mount the configuration from a ConfigMap, and secrets (key passphrase, OIDC client secret, LDAP password) from Secrets as files.
  • Expose metrics only inside the cluster, with a NetworkPolicy that lets only Prometheus in.