5,6 KiB
5,6 KiB
name: deploy-to-vps description: Publish a website or an app (static site, Node.js, PHP or WordPress) on the user's MozOut VPS: find the server and its IP through the MozOut API, prepare the project with Docker Compose and Caddy for automatic HTTPS, copy it over SSH, start it and connect the domain. Use when the user says "deploy this to my VPS", "put my site online on my server" or "host this project on MozOut".
Deploy to a MozOut VPS
A guided task. The API finds and manages the server; the files go over SSH with the user's own access. Ready examples live in the templates repository: https://git.mozout.com/mozout-com/templates
Setup
- API address:
https://api.mozout.com/v1. It is fixed for MozOut: never ask the user for another address. - API key: always read it from the
MOZOUT_API_KEYenvironment variable. Check it without printing it:test -n "$MOZOUT_API_KEY" && echo set || echo missing - If it is missing, ask the user to create a key in the API Center (https://www.my.mozout.com/api-center.php) with
vps:read(plusdns:writeto connect the domain, andvps:writeonly if a restart or backup is needed), then to runexport MOZOUT_API_KEY="sandbox_..."and restart Claude Code (or the editor). sandbox_keys read the real account but only simulate writes and never charge.prod_keys change the account and can charge.GET /v1/tokengives the mode indata.modeand the permissions indata.permissions. Suggest asandbox_key for a first try.- Never print, log or commit the key, and never put it in code that runs in a browser or a mobile app. In code, read it from the environment.
Every request looks like this:
curl -sS "https://api.mozout.com/v1/PATH" -H "Authorization: Bearer $MOZOUT_API_KEY" -H "Accept: application/json"
Rules
- Before anything that charges, deletes data or cannot be undone, tell the user exactly what will happen (with the price, when the API gives one) and wait for a clear yes.
- Send an
Idempotency-Keyheader on purchases, sends and other POST requests that accept it, and reuse the same value if you retry the same request:IDEM=$(uuidgen 2>/dev/null || cat /proc/sys/kernel/random/uuid). - Lists come in pages:
?page=1&per_page=100, andmeta.total_pagessays how many there are. - Long operations answer
202with anaction_id. Follow them withGET /v1/actions/{action_id}every 10 to 20 seconds untilstatusisdoneorfailed. - Answer the user in the language they write in, and show amounts with the currency the API returns.
Steps
- Pick the server.
GET /v1/serversand showname,ip,status,power_stateandoperating_system. If there are several, ask which one. Ifpower_stateis notrunning, offer to start it (manage-vps). - Check access. Ask how the user connects (
ssh root@<ip>or another user with a key). Never ask for the root password in the chat, and never generate a new one unless the user asks (manage-vps). Test withssh -o BatchMode=yes USER@IP true. - Prepare the project. Pick the closest template (static site, Node.js, PHP, WordPress) and add its
docker-compose.yml,Caddyfileand.env.exampleto the project. Keep secrets in.envon the server only, and add.envto.gitignore. - Suggest a backup of the server first (
POST /v1/servers/{id}/backups) if it already runs other sites. - Install Docker on the server if it is missing (
docker --version). On Ubuntu or Debian, use the official Docker packages for that system. Ask before installing anything. - Copy and start.
rsync -az --exclude .git --exclude node_modules --exclude .env ./ USER@IP:/srv/app/
ssh USER@IP 'cd /srv/app && test -f .env || cp .env.example .env'
ssh USER@IP 'cd /srv/app && docker compose up -d --build && docker compose ps'
- Connect the domain with the
connect-domainskill (A record of@andwwwto the server IP). Caddy gets the HTTPS certificate on its own once the domain points to the server and ports 80 and 443 are open. - Check.
curl -I https://mybusiness.comandssh USER@IP 'cd /srv/app && docker compose logs --tail=50'.
Rules
- Do not open other ports, change the firewall, delete files or stop other containers on the server without asking.
- Never copy
.env, keys or database dumps into git or into the chat. - Updates: copy again and run
docker compose up -d --build. To go back, keep the previous release folder or use a server backup.
Errors
Errors look like {"error": {"code", "message", "correlation_id", "details"}}. Act on code, never on the text of message.
| HTTP | code | What to do |
|---|---|---|
| 401 | unauthorized |
The key is missing, wrong or revoked. Ask the user to check MOZOUT_API_KEY. |
| 402 | insufficient_credit |
Not enough account credit, and nothing was charged. Give the user details.add_funds_url. |
| 403 | insufficient_scope |
The key lacks a permission. Name it and ask for a key that has it. |
| 403 | spending_limit_exceeded |
The purchase goes over the key spending limit. Nothing was charged. |
| 404 | not_found |
Wrong id, or it is not in this account. |
| 409 | conflict and others |
Read details.reason and explain it in plain words. |
| 422 | validation_failed |
Fix the field named in details and try again. |
| 429 | rate_limited |
Wait for the Retry-After seconds, then try once more. |
| 5xx | internal_error, upstream_error |
Try again later. If the user contacts support, give them the correlation_id. |
More
- Servers: https://docs.mozout.com/servers/
- DNS: https://docs.mozout.com/dns/
- Full reference: https://api.mozout.com/v1/openapi.json