Kez/kez-chat/deploy/install-docker.sh
Tudisco f79979669c deploy(kez-chat): add deploy.sh + install-docker.sh
Two helper scripts in kez-chat/deploy/ so deployment is one command
once SSH access is set up:

- install-docker.sh — run once on a fresh Ubuntu host. Installs
  Docker Engine + Compose plugin from Docker's apt repo, adds the
  current user to the docker group, enables the systemd unit.
  Idempotent (safe to re-run).

- deploy.sh — run from a workstation. Rsyncs the three subdirs we
  need (rust/, kez-chat/, rust-sig-server/) to the target host,
  excludes build artifacts (target/, node_modules/, *.db), then
  SSHes in to run docker compose up -d --build, waits for the
  chat-server healthcheck.

Defaults match what we agreed:
  host  = tudisco@10.5.2.5
  path  = /home/tudisco/kez-chat
  server domain = kez.lat

Overridable via flags or env vars.
2026-05-24 23:38:58 -06:00

58 lines
1.7 KiB
Bash
Executable File

#!/usr/bin/env bash
# Run this ONCE on a fresh Ubuntu host to install Docker + Compose v2 and
# add the current user to the `docker` group so subsequent commands don't
# need sudo.
#
# Requires sudo. Idempotent — safe to re-run.
#
# Usage:
# ssh tudisco@host 'bash -s' < install-docker.sh
# or:
# scp install-docker.sh tudisco@host:~/
# ssh tudisco@host 'bash ~/install-docker.sh'
set -euo pipefail
echo "==> Updating apt"
sudo apt-get update -y
echo "==> Installing prerequisites"
sudo apt-get install -y --no-install-recommends \
ca-certificates curl gnupg
echo "==> Adding Docker's official GPG key"
sudo install -m 0755 -d /etc/apt/keyrings
if [[ ! -f /etc/apt/keyrings/docker.gpg ]]; then
curl -fsSL https://download.docker.com/linux/ubuntu/gpg \
| sudo gpg --dearmor -o /etc/apt/keyrings/docker.gpg
sudo chmod a+r /etc/apt/keyrings/docker.gpg
fi
echo "==> Adding Docker apt repo"
. /etc/os-release
echo "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.gpg] \
https://download.docker.com/linux/ubuntu ${VERSION_CODENAME} stable" \
| sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
echo "==> Installing Docker Engine + Compose plugin"
sudo apt-get update -y
sudo apt-get install -y \
docker-ce docker-ce-cli containerd.io \
docker-buildx-plugin docker-compose-plugin
echo "==> Adding $USER to docker group"
sudo usermod -aG docker "$USER"
echo "==> Enabling + starting Docker"
sudo systemctl enable --now docker
echo
echo "==> Versions:"
docker --version
docker compose version
echo
echo "✓ Docker installed."
echo " IMPORTANT: log out and back in (or run 'newgrp docker') for the"
echo " group change to take effect; otherwise 'docker' commands need sudo."