agentleFS
aniq-ui-proaniq-ui-pro/agent-skills/skills/vps-deploy/SKILL.md

vps-deploy

Skill1 starsChanged 2 days agoMITView on GitHub

Deploy a Next.js App Router site, a Next.js dashboard and a NestJS API with its database (Postgres, MySQL or SQLite) to one Ubuntu VPS with Docker Compose and Caddy for automatic HTTPS, over SSH, one approved step at a time, with nightly database backups to S3-compatible storage and a restore test. Use when the user asks to deploy, self-host or move such a project to a VPS or their own server.

  • Reads credentials
  • Deletes or force-pushes

4 other projects use a version of this.

Adopted by

Most recently taken up by

The file

Show its rules and text

We split this skill into the rules it gives an agent

13 rules. About 0 are common, 1 is distinctive, and 12 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈1

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 12

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Very specific:

    Never a loop that reconnects to poll.

    line 16
  2. Very specific:

    Check: 0 FAIL. Note each app's port and NEXT_PUBLIC_ variables, the API's health route, the database, its one-time schema command, and the …

    line 34
  3. Very specific:

    Check: dig +short <domain> prints IP for each one.

    line 41
  4. Very specific:

    Check: ufw status verbose lists only 22, 80 and 443, and step 4's check still passes.

    line 47
  5. Very specific:

    Check: ssh -o BatchMode=yes -o PubkeyAuthentication=no HOST true ends in Permission denied (publickey) with no password listed, root@IP is …

    line 55
  6. Very specific:

    Check: ssh HOST 'sh -s -- ROOT' < ${CLAUDE_SKILL_DIR}/scripts/server-check.sh has no FAIL in the settings lines.

    line 62
  7. Very specific:

    Ship and start: Ask the user to commit first: git status --porcelain must be empty.

    line 64
  8. Very specific:

    Check: the server prints the same commit as git rev-parse --short HEAD, --wait exits 0, and server-check shows every service running and …

    line 69
  9. Very specific:

    Check: 0 failed: ports 22, 80, 443 open and the rest closed, HTTP redirects to HTTPS, each site answers, each certificate is valid.

    line 72
  10. Very specific:

    Run ROOT/ops/db-backup.sh ROOT/env/backup.env once, then add the two cron lines from reference.md.

    line 76
  11. Very specific:

    Check: the run prints OK for the dump and copied to the remote.

    line 78
  12. Very specific:

    Check: the last line starts with PASS and every table is ok.

    line 80
  13. Distinctive:

    Check: step 10's probe passes and the server prints the new commit.

    line 84

≈ “Common” is an estimate: at least 1 in 5 of the 364,980 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

Deploy to one VPS with Docker Compose and Caddy

Work in the numbered steps below. Each step ends with a check; run it, show the result, and stop at the first check that fails. Report what failed and wait for the user.

Safety rules

  • One SSH connection per step: a single ssh HOST '...', or ssh HOST 'sh -s' < script. Never a loop that reconnects to poll. With ufw limit 22/tcp, an address that opens 6 connections in 30 seconds is refused.
  • No secret passes through the chat. Generate secrets on the server, straight into the file. Third-party keys are typed by the user into the file in their own SSH session. Print setting names, never values, and never cat an env file.
  • Ask before anything destructive and say what it deletes: docker compose down -v, docker volume rm, DROP DATABASE (other than restore_check), rm -rf outside a temp folder, overwriting an env file, a ufw change that could cut off SSH, any script that resets or drops data.
  • Only Caddy publishes ports (80 and 443). Docker-published ports skip ufw.
  • Only committed code goes to the server (git archive HEAD). Local .env files never do.

Names used below: IP 203.0.113.10, HOST deploy@IP, ROOT /srv/shop, and DC = cd ROOT/app/deploy && RELEASE=$(cat ../RELEASE) docker compose --env-file ROOT/env/compose.env.

Steps

  1. Read the project. node ${CLAUDE_SKILL_DIR}/scripts/preflight.mjs . Check: 0 FAIL. Note each app's port and NEXT_PUBLIC_ variables, the API's health route, the database, its one-time schema command, and the scripts the report says delete data.
  2. Write the deploy files from reference.md: deploy/compose.yml, deploy/caddy/Caddyfile, deploy/env.example/*.env, and the .gitignore lines. Commit them. Check: ENV_DIR=$PWD/deploy/env.example node ${CLAUDE_SKILL_DIR}/scripts/preflight.mjs . --compose deploy/compose.yml --env-file deploy/env.example/compose.env reports the compose file valid and 0 FAIL.
  3. DNS. The user points an A record for every domain at IP now, so it resolves by step 10. Check: dig +short <domain> prints IP for each one.
  4. SSH user with a key (as root@IP, Ubuntu 24.04 or 26.04): create deploy with no password, copy root's authorized_keys to it, create ROOT and /srv/backups owned by it. Check: ssh -o BatchMode=yes HOST true exits 0.
  5. Firewall (as root): ufw default deny incoming, ufw default allow outgoing, ufw limit 22/tcp, ufw allow 80/tcp, ufw allow 443, then ufw --force enable. Check: ufw status verbose lists only 22, 80 and 443, and step 4's check still passes.
  6. Docker (as root): Docker's apt repository for Ubuntu (fetch docs.docker.com/engine/install/ubuntu; not the convenience script), then usermod -aG docker deploy. Check: ssh HOST 'docker version --format "{{.Server.Version}}" && docker compose version'.
  7. Close root and password logins (last root step): /etc/ssh/sshd_config.d/10-hardening.conf with PermitRootLogin no, PasswordAuthentication no, KbdInteractiveAuthentication no; sshd -t && systemctl restart ssh (open sessions stay connected). Check: ssh -o BatchMode=yes -o PubkeyAuthentication=no HOST true ends in Permission denied (publickey) with no password listed, root@IP is refused, and step 4's check passes.
  8. Settings on the server. Copy deploy/env.example/*.env to ROOT/env (folder 700, files 600) with one tar | ssh. Fill generated secrets in place, for example sed -i "s/^JWT_SECRET=.*/JWT_SECRET=$(openssl rand -hex 48)/" api.env, with the same generated database password in both files. The user adds third-party keys themselves. Check: ssh HOST 'sh -s -- ROOT' < ${CLAUDE_SKILL_DIR}/scripts/server-check.sh has no FAIL in the settings lines.
  9. Ship and start. Ask the user to commit first: git status --porcelain must be empty. git archive HEAD | ssh HOST '...' into a temp folder on the server, write the short commit to RELEASE, then rsync -a --delete it into ROOT/app. Then, in one connection: DC build, DC up -d --wait db, the schema command once with DC run --rm api ..., DC up -d --wait. Check: the server prints the same commit as git rev-parse --short HEAD, --wait exits 0, and server-check shows every service running and healthy.
  10. HTTPS from outside. node ${CLAUDE_SKILL_DIR}/scripts/probe.mjs IP <every domain> --health https://<api domain>/<health route> Check: 0 failed: ports 22, 80, 443 open and the rest closed, HTTP redirects to HTTPS, each site answers, each certificate is valid.
  11. Nightly backup. Copy db-backup.sh, restore-check.sh and server-check.sh to ROOT/ops with one tar | ssh. The user fills the bucket keys in ROOT/env/backup.env. Run ROOT/ops/db-backup.sh ROOT/env/backup.env once, then add the two cron lines from reference.md. Check: the run prints OK for the dump and copied to the remote; crontab -l shows both lines.
  12. Restore test. ssh HOST 'ROOT/ops/restore-check.sh ROOT/env/backup.env' Check: the last line starts with PASS and every table is ok.
  13. Every later deploy: step 9's ship, then DC build && DC up -d --wait, then DC exec -T -w /etc/caddy caddy caddy reload --config /etc/caddy/Caddyfile if the Caddyfile changed. Roll back with RELEASE=<old commit> and up -d --wait --no-build. Check: step 10's probe passes and the server prints the new commit.

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.