إنتقل إلى المحتوى الرئيسي

VPS Deployment Guide (api.gpkeys.com, Docker + central-caddy)

GpkeysBot-Api-doc is deployed cleanly on https://api.gpkeys.com as an isolated, stateless non-root nginx:1.27-alpine Docker container named gpkeysbot-api-doc-web, listening internally on port 3141 with zero database or Redis dependencies.

Traffic arrives through your existing central-caddy reverse proxy over the shared external proxy Docker network:

  • Do not deploy another Caddy container.
  • Do not publish ports 80, 443, or host ports from this container.
  • Keep this container completely isolated from other VPS services, databases, and containers.

1. Architecture Summary​

Internet -> DNS A (api.gpkeys.com -> VPS_PUBLIC_IP)
-> central-caddy (ports 80/443, automatic HTTPS/TLS)
-> external Docker network: proxy
-> gpkeysbot-api-doc-web:3141 (non-root nginx:1.27-alpine, read-only rootfs)

Inside gpkeysbot-api-doc-web:3141:

  • / serves the portal homepage, /docs/*, /api-reference, /openapi.yaml, /fr/*, and RTL /ar/*.
  • /api/ serves a complete subpath mirror (/api/, /api/docs/*, /api/api-reference, /api/openapi.yaml) using relative redirects (absolute_redirect off; port_in_redirect off;) so central-caddy preserves HTTPS without leaking internal port 3141.

2. DNS Record​

Ensure the DNS record for api.gpkeys.com points to your VPS public IP (VPS_PUBLIC_IP):

TypeHost / NameValuePurpose
Aapi (api.gpkeys.com)VPS_PUBLIC_IPServes https://api.gpkeys.com via central-caddy

Confirm resolution before reloading Caddy (dig +short api.gpkeys.com).


3. Environment Configuration (.env)​

Copy .env.example to .env on the VPS:

COMPOSE_PROJECT_NAME=gpkeysbot-api-doc
DOCS_SITE_URL=https://api.gpkeys.com
DOCS_BASE_URL=/
ENABLE_API_SUBPATH=true
API_PUBLIC_URL=https://api.example.com
TELEGRAM_BOT_URL=https://t.me/TODO_VERIFY_GPKEYS_BOT
SUPPORT_CONTACT_URL=https://t.me/Etkeys

Set API_PUBLIC_URL, TELEGRAM_BOT_URL, and SUPPORT_CONTACT_URL cleanly before building (TODO(verify) backend REST API host URL if separate from api.gpkeys.com).


4. central-caddy Configuration​

Add this site block to your existing central-caddy Caddyfile (see deploy/caddy/gpkeysbot-api-doc.Caddyfile.example):

api.gpkeys.com {
encode gzip zstd
reverse_proxy gpkeysbot-api-doc-web:3141
}

5. Manual VPS Deployment & Updates (./deplo.sh)​

git clone https://github.com/itsnajeh/GpkeysBot-api-doc.git ~/GpkeysBot-Api-doc
cd ~/GpkeysBot-Api-doc

cp .env.example .env
chmod +x deplo.sh
./deplo.sh

Then validate and reload central-caddy safely without modifying existing project blocks:

docker exec central-caddy caddy validate --config /etc/caddy/Caddyfile
docker exec central-caddy caddy reload --config /etc/caddy/Caddyfile

For future updates after git push:

cd ~/GpkeysBot-Api-doc && ./deplo.sh --pull

6. Verification Commands​

# 1. Confirm container is running & healthy
docker ps --filter name=gpkeysbot-api-doc-web
docker inspect --format '{{.State.Health.Status}}' gpkeysbot-api-doc-web

# 2. Confirm attached to existing `proxy` network
docker network inspect proxy --format '{{range .Containers}}{{.Name}} {{end}}'

# 3. Verify internal HTTP endpoints inside container
docker exec gpkeysbot-api-doc-web wget -qO- http://127.0.0.1:3141/healthz
docker exec gpkeysbot-api-doc-web wget -q --spider http://127.0.0.1:3141/
docker exec gpkeysbot-api-doc-web wget -q --spider http://127.0.0.1:3141/api/

# 4. Confirm central-caddy reaches gpkeysbot-api-doc-web:3141 over `proxy`
docker exec central-caddy wget -qO- http://gpkeysbot-api-doc-web:3141/healthz

# 5. External domain & HTTPS verification
curl -I https://api.gpkeys.com/
curl -I https://api.gpkeys.com/api/