BosskuAI VPS Docker Deployment
Use this skill when deploying a Laravel, Nuxt, Node, Go, or multi-service app to a single VPS (or a small pair) with Docker, on Hostinger, Hetzner, DigitalOcean, Linode, or a bare cloud VM.
How this differs from nearby skills
bosskuai-docker: the Dockerfile and Compose files themselves; this skill puts them on a server and keeps them running.
bosskuai-hostinger-hosting: Hostinger panel, plans, non-Docker layouts, and compromise recovery; use both when the VPS is Hostinger.
bosskuai-aws-deployment: move there when you need managed databases, autoscaling, or compliance boundaries.
bosskuai-devops-iac: pipeline and infra principles; this skill is the single-box implementation.
bosskuai-ci-cd-pipelines: builds and pushes the image; this skill pulls and runs it.
Mindset
- One box means one blast radius: backups off the box, secrets off the image, rollback by tag.
- Build on CI, run on the server; never build production images on the VPS.
- Everything a restore needs (env, compose, volumes, DNS) is written down and tested.
- The proxy owns TLS and exposure; app containers publish nothing to the host.
Provisioning baseline
- Ubuntu LTS;
deploy user with sudo; SSH keys only; PermitRootLogin no, PasswordAuthentication no.
- UFW (SSH, 80, 443) and fail2ban;
unattended-upgrades; swap sized for the plan; vm.overcommit_memory=1 if Redis runs here.
- UFW does not filter ports Docker publishes (Docker writes its own iptables rules): publish only the proxy, bind anything else to
127.0.0.1:PORT:PORT, and check exposure from outside the box.
- Docker CE from the official repository;
deploy in the docker group (this is root-equivalent; treat the user accordingly); daemon log-driver: json-file with max-size/max-file.
- A private registry token (GHCR, ECR, Docker Hub) for pulls; no build tools on the box.
- Know the versions on the box: the Ubuntu release, Docker Engine and Compose (
docker version, docker compose version). Check each support end date live on the vendor's page. After standard security maintenance ends, an Ubuntu LTS gets security fixes only with Ubuntu Pro (ESM). Without Pro, it gets none, even with unattended-upgrades on. Check both dates for your release on ubuntu.com/about/release-cycle.
Compose topology
- One compose project per environment (
/srv/<app>/<env>/): compose.yml + .env (600) + overrides per env.
- Proxy: Caddy (automatic TLS, simplest), Traefik (labels, multi-app), or nginx + certbot. Only the proxy publishes 80/443.
- Services:
app (php-fpm+nginx image, FrankenPHP/Octane, Node, or Go), worker (queue), scheduler (schedule:run loop or cron container), db (named volume, internal network only), redis, optional meilisearch/minio.
- Networks:
edge (proxy ↔ app) and internal (app ↔ db/redis); db and redis never on edge.
- Health checks on every service;
restart: unless-stopped; memory limits on app and db; pinned image tags.
- Stop cleanly:
stop_grace_period longer than the longest request or job. SIGKILL drops the work in progress, so jobs must be safe to run twice. Run one scheduler replica: two of them fire each due task twice unless the tasks use a shared lock.
Deploy flow
- CI builds the image, tags
sha-<short> and env-latest, pushes to the registry. Deploy and roll back by the sha- tag or the digest only: env-latest moves, so never roll back to it.
- Server:
IMAGE_TAG=sha-<short> docker compose pull app worker scheduler, then run migrations with the same tag: IMAGE_TAG=sha-<short> docker compose run --rm app php artisan migrate --force (gated; migrations backward compatible with the running version). Wrap the whole deploy in a lock (for example flock), so two runs never migrate or swap at the same time.
- Roll:
IMAGE_TAG=sha-<short> docker compose up -d --wait --no-deps app worker scheduler; the proxy routes to healthy containers only.
- Zero-downtime: two
app replicas behind the proxy with start_first rollout, or blue/green compose projects on alternate ports swapped in the proxy config.
- Post-deploy: health URL, one authenticated request, queue processes a job, logs clean for 5 minutes.
- Rollback:
IMAGE_TAG=<previous> docker compose up -d --wait app worker scheduler; keep the last five tags in the registry. Do not run docker image prune -a between deploys, because it deletes the images you would roll back to. Watch disk with docker system df: a full disk can stop the database and fail the next deploy.
Stack notes
- Laravel:
route:cache and view:cache at image build; config:cache in the container entrypoint at start, once the runtime env exists (at build it bakes build-time values, or secrets if .env is in the build context); storage/ and uploads on a volume; queue:work --tries=3 --max-time=3600 under compose restart; scheduler as while true; do php artisan schedule:run; sleep 60; done or supercronic; Reverb/Horizon as separate services.
- Nuxt / Node: run the Nitro/Node server as a non-root user;
NITRO_PORT, NUXT_* runtime config from env; no pnpm install at runtime.
- Go: static binary on a scratch or distroless image;
GOMEMLIMIT set to the container limit.
- Database:
POSTGRES_*/MYSQL_* from .env; tuned shared_buffers/innodb_buffer_pool_size to the plan; never publish the port.
Backups and restore
- Nightly
pg_dump -Fc or mysqldump --single-transaction from a sidecar, plus uploads volume, shipped off-box with restic or rclone to S3-compatible/B2 storage; encrypted; 30-day retention.
- Provider snapshots are for quick rollback, not backups.
- A rollback restores code, not rows. Before a release that changes the schema, take a fresh dump, and write down the reverse step or the restore that undoes what the new version wrote.
- Quarterly restore drill into a scratch VPS: time it, record it in the runbook.
Monitoring
- External uptime check on the health URL; disk, memory, and container-restart alerts (node exporter + Grafana Cloud, or Uptime Kuma + a cron disk check).
- Centralized logs optional (Loki/Vector) once more than one box exists; until then
docker compose logs with rotation.
- Certificate expiry alert even with auto-renewal.
Verification
docker compose config --quiet && docker compose ps
docker compose logs --tail=100 app worker
curl -fsS https://<domain>/healthz
ufw status verbose && sshd -T | grep -Ei 'permitrootlogin|passwordauthentication'
restic snapshots | tail -3 # or the equivalent for your backup tool
Guardrails
- Do not expose database, Redis, or internal services publicly; do not publish their ports.
- Do not build images or run
composer install/npm install on the production box.
- Do not deploy a database-affecting release without a fresh backup and a rollback tag.
- Do not use
latest tags in production.
- Do not keep secrets in images, compose files, or git;
.env on the box only, 600.
Output format
Target: [provider, plan, OS] - Stack: [services]
Hardening state: [ssh, firewall, fail2ban, updates, docker logging]
Compose topology: [proxy, app, worker, scheduler, db, redis, networks, volumes]
Deploy steps: [pull → migrate → up --wait → verify]
Zero-downtime approach: [replicas | blue/green | none, why]
Rollback: [previous tag command]
Backups: [what, where off-box, last restore drill]
Monitoring: [uptime, disk, restarts, cert expiry]
Production blockers: [P0 items]
References
../../references/playbooks/bosskuai-vps-docker-deployment-playbook.md
../../references/checklists/vps-docker-deployment-checklist.md
../../references/checklists/docker-checklist.md
../../references/checklists/hostinger-hosting-checklist.md
../../references/checklists/engineering-quality-bar.md
1---2name: bosskuai-vps-docker-deployment3description: "Use when deploying Docker workloads to a VPS, including hardening, production Compose, Caddy, Traefik or nginx TLS proxies, registry deploys, low-downtime rollout, migrations, off-box backups, restore drills, monitoring, firewalls, and rollback planning."4metadata:5 source: https://skillmd.com/skills/wankimmy/bosskuai-vps-docker-deployment6---78# BosskuAI VPS Docker Deployment910Use this skill when deploying a Laravel, Nuxt, Node, Go, or multi-service app to a single VPS (or a small pair) with Docker, on Hostinger, Hetzner, DigitalOcean, Linode, or a bare cloud VM.1112## How this differs from nearby skills1314- **`bosskuai-docker`**: the Dockerfile and Compose files themselves; this skill puts them on a server and keeps them running.15- **`bosskuai-hostinger-hosting`**: Hostinger panel, plans, non-Docker layouts, and compromise recovery; use both when the VPS is Hostinger.16- **`bosskuai-aws-deployment`**: move there when you need managed databases, autoscaling, or compliance boundaries.17- **`bosskuai-devops-iac`**: pipeline and infra principles; this skill is the single-box implementation.18- **`bosskuai-ci-cd-pipelines`**: builds and pushes the image; this skill pulls and runs it.1920## Mindset2122- One box means one blast radius: backups off the box, secrets off the image, rollback by tag.23- Build on CI, run on the server; never build production images on the VPS.24- Everything a restore needs (env, compose, volumes, DNS) is written down and tested.25- The proxy owns TLS and exposure; app containers publish nothing to the host.2627## Provisioning baseline28291. Ubuntu LTS; `deploy` user with sudo; SSH keys only; `PermitRootLogin no`, `PasswordAuthentication no`.302. UFW (SSH, 80, 443) and fail2ban; `unattended-upgrades`; swap sized for the plan; `vm.overcommit_memory=1` if Redis runs here.31- UFW does not filter ports Docker publishes (Docker writes its own iptables rules): publish only the proxy, bind anything else to `127.0.0.1:PORT:PORT`, and check exposure from outside the box.323. Docker CE from the official repository; `deploy` in the `docker` group (this is root-equivalent; treat the user accordingly); daemon `log-driver: json-file` with `max-size`/`max-file`.334. A private registry token (GHCR, ECR, Docker Hub) for pulls; no build tools on the box.345. Know the versions on the box: the Ubuntu release, Docker Engine and Compose (`docker version`, `docker compose version`). Check each support end date live on the vendor's page. After standard security maintenance ends, an Ubuntu LTS gets security fixes only with Ubuntu Pro (ESM). Without Pro, it gets none, even with `unattended-upgrades` on. Check both dates for your release on ubuntu.com/about/release-cycle.3536## Compose topology3738- One compose project per environment (`/srv/<app>/<env>/`): `compose.yml` + `.env` (`600`) + `overrides` per env.39- Proxy: Caddy (automatic TLS, simplest), Traefik (labels, multi-app), or nginx + certbot. Only the proxy publishes 80/443.40- Services: `app` (php-fpm+nginx image, FrankenPHP/Octane, Node, or Go), `worker` (queue), `scheduler` (`schedule:run` loop or cron container), `db` (named volume, internal network only), `redis`, optional `meilisearch`/`minio`.41- Networks: `edge` (proxy ↔ app) and `internal` (app ↔ db/redis); db and redis never on `edge`.42- Health checks on every service; `restart: unless-stopped`; memory limits on app and db; pinned image tags.43- Stop cleanly: `stop_grace_period` longer than the longest request or job. SIGKILL drops the work in progress, so jobs must be safe to run twice. Run one scheduler replica: two of them fire each due task twice unless the tasks use a shared lock.4445## Deploy flow46471. CI builds the image, tags `sha-<short>` and `env-latest`, pushes to the registry. Deploy and roll back by the `sha-` tag or the digest only: `env-latest` moves, so never roll back to it.482. Server: `IMAGE_TAG=sha-<short> docker compose pull app worker scheduler`, then run migrations with the same tag: `IMAGE_TAG=sha-<short> docker compose run --rm app php artisan migrate --force` (gated; migrations backward compatible with the running version). Wrap the whole deploy in a lock (for example `flock`), so two runs never migrate or swap at the same time.493. Roll: `IMAGE_TAG=sha-<short> docker compose up -d --wait --no-deps app worker scheduler`; the proxy routes to healthy containers only.504. Zero-downtime: two `app` replicas behind the proxy with `start_first` rollout, or blue/green compose projects on alternate ports swapped in the proxy config.515. Post-deploy: health URL, one authenticated request, queue processes a job, logs clean for 5 minutes.526. Rollback: `IMAGE_TAG=<previous> docker compose up -d --wait app worker scheduler`; keep the last five tags in the registry. Do not run `docker image prune -a` between deploys, because it deletes the images you would roll back to. Watch disk with `docker system df`: a full disk can stop the database and fail the next deploy.5354## Stack notes5556- **Laravel**: `route:cache` and `view:cache` at image build; `config:cache` in the container entrypoint at start, once the runtime env exists (at build it bakes build-time values, or secrets if `.env` is in the build context); `storage/` and uploads on a volume; `queue:work --tries=3 --max-time=3600` under compose restart; scheduler as `while true; do php artisan schedule:run; sleep 60; done` or supercronic; Reverb/Horizon as separate services.57- **Nuxt / Node**: run the Nitro/Node server as a non-root user; `NITRO_PORT`, `NUXT_*` runtime config from env; no `pnpm install` at runtime.58- **Go**: static binary on a scratch or distroless image; `GOMEMLIMIT` set to the container limit.59- **Database**: `POSTGRES_*`/`MYSQL_*` from `.env`; tuned `shared_buffers`/`innodb_buffer_pool_size` to the plan; never publish the port.6061## Backups and restore6263- Nightly `pg_dump -Fc` or `mysqldump --single-transaction` from a sidecar, plus uploads volume, shipped off-box with `restic` or `rclone` to S3-compatible/B2 storage; encrypted; 30-day retention.64- Provider snapshots are for quick rollback, not backups.65- A rollback restores code, not rows. Before a release that changes the schema, take a fresh dump, and write down the reverse step or the restore that undoes what the new version wrote.66- Quarterly restore drill into a scratch VPS: time it, record it in the runbook.6768## Monitoring6970- External uptime check on the health URL; disk, memory, and container-restart alerts (node exporter + Grafana Cloud, or Uptime Kuma + a cron disk check).71- Centralized logs optional (Loki/Vector) once more than one box exists; until then `docker compose logs` with rotation.72- Certificate expiry alert even with auto-renewal.7374## Verification7576```bash77docker compose config --quiet && docker compose ps78docker compose logs --tail=100 app worker79curl -fsS https://<domain>/healthz80ufw status verbose && sshd -T | grep -Ei 'permitrootlogin|passwordauthentication'81restic snapshots | tail -3 # or the equivalent for your backup tool82```8384## Guardrails8586- Do not expose database, Redis, or internal services publicly; do not publish their ports.87- Do not build images or run `composer install`/`npm install` on the production box.88- Do not deploy a database-affecting release without a fresh backup and a rollback tag.89- Do not use `latest` tags in production.90- Do not keep secrets in images, compose files, or git; `.env` on the box only, `600`.9192## Output format9394```text95Target: [provider, plan, OS] - Stack: [services]96Hardening state: [ssh, firewall, fail2ban, updates, docker logging]97Compose topology: [proxy, app, worker, scheduler, db, redis, networks, volumes]98Deploy steps: [pull → migrate → up --wait → verify]99Zero-downtime approach: [replicas | blue/green | none, why]100Rollback: [previous tag command]101Backups: [what, where off-box, last restore drill]102Monitoring: [uptime, disk, restarts, cert expiry]103Production blockers: [P0 items]104```105106## References107108- `../../references/playbooks/bosskuai-vps-docker-deployment-playbook.md`109- `../../references/checklists/vps-docker-deployment-checklist.md`110- `../../references/checklists/docker-checklist.md`111- `../../references/checklists/hostinger-hosting-checklist.md`112- `../../references/checklists/engineering-quality-bar.md`