Setting up Hosty CLI
Hosty CLI is the command line tool you use to work with the environments and backups of your project. It comes as the Docker image systemseed/hosty with everything it needs inside, so all you install is Docker.
Before you start, finish Setting up a new user: you need your access keys in ~/.aws and the VPN.
What you need
- Docker with Docker Compose. Docker Desktop has both.
- The project in Git, with its Hosty configuration in .hosty/hosty.yaml (see Project configuration).
1. Pin the version of Hosty CLI
Add the version of Hosty CLI to .env in the root of the project. Docker Compose reads this file on its own:
HOSTY_TAG=1.5.2Use the latest release from the tags on Docker Hub (vX.Y.Z). Pin a release rather than latest: everyone on the project and CI then run the same version, and you update it on purpose.
Hosty CLI checks for new releases on every command. A new patch release (i.e. 1.5.3 for 1.5.2) only prints a message. A new minor or major release (i.e. 1.6.0) stops all commands of older versions until you update HOSTY_TAG. In an emergency, i.e. to fix production before you can update, skip the check for one command:
docker compose run --rm -e HOSTY_SKIP_VERSION_CHECK=1 hosty_cli hosty <command>2. Add Hosty CLI to compose.yml
Add the service to compose.yml in the root of the project, next to .git:
services:
hosty_cli:
image: systemseed/hosty:v${HOSTY_TAG}
volumes:
# The root of the project, where .git and .hosty are. Hosty CLI reads
# the configuration and builds images from here.
- ./:/src/project
# Your access keys (profile "hosty.user") and the MFA session.
- ~/.aws:/src/.aws
# The Docker of your computer, to build images.
- /var/run/docker.sock:/var/run/docker.sockIf compose.yml is in a subfolder, i.e. .docker/, map the root of the project with ../:/src/project instead. If your access keys are in another folder than ~/.aws, map that folder to /src/.aws.
3. Add a helper script
Typing docker compose run --rm hosty_cli hosty every time is tedious, so add a small script to the root of the project:
cat > hosty.sh <<'EOF'
#!/usr/bin/env bash
# Runs Hosty CLI in its container, i.e. "./hosty.sh ls".
cd "$(dirname "$0")" && exec docker compose run --rm hosty_cli hosty "$@"
EOF
chmod +x hosty.shThe examples in these docs use hosty <command>. With the script, that is ./hosty.sh <command>.
4. Check that it works
- List the commands of Hosty CLI:
./hosty.sh list- Start a session with two-factor authentication. Hosty CLI asks for a code from your authenticator app:
./hosty.sh authThe session lasts 12 hours. Commands that need it, such as downloading backups, ask for a code again when it has expired.
- Connect to the VPN and list the environments of the project:
./hosty.sh lsTo learn more about a command and its options, add --help, i.e. ./hosty.sh logs --help.