# Hosting Two supported ways to host: **A) bare-metal (systemd + Nginx)** and **B) Docker Compose**. Both need PostgreSQL and a `JWT_SECRET`. ## Option A — Bare-metal (Node.js + Nginx + PostgreSQL) ### 1. Provision - Server with Ubuntu 22.04+/Debian 12+, Node.js 20, PostgreSQL 14+, Nginx, Certbot. - DNS `openstack.example.com` pointing at the server. ```bash sudo apt update && sudo apt install -y nodejs npm postgresql nginx certbot python3-certbot-nginx ``` ### 2. Database ```bash sudo -u postgres psql -c "CREATE USER openstack WITH PASSWORD 'strong-password';" sudo -u postgres psql -c "CREATE DATABASE openstack OWNER openstack;" psql "postgres://openstack:strong-password@localhost:5432/openstack" < backend/src/db/schema.sql ``` ### 3. Backend (systemd) ```bash git clone https://git.sysdaemon.xyz/x3/openStack.git /opt/openStack cd /opt/openStack/backend && npm ci --omit=dev cat > /opt/openStack/backend/.env < backup-$(date +%F).sql.gz ``` --- ## Option B — Docker Compose (recommended for VPS / homelab) Requirements: Docker Engine + Compose plugin. ```bash git clone https://git.sysdaemon.xyz/x3/openStack.git cd openStack cp .env.example .env # IMPORTANT: set POSTGRES_PASSWORD and JWT_SECRET to strong values nano .env docker compose up -d --build docker compose logs -f backend curl http://localhost:3000/api/health ``` - Frontend: `http://:8080` - Backend API: `http://:3000/api/health` - Data persists in the `pgdata` volume. ### Reverse proxy (TLS) in front of Compose Point Nginx/Caddy at `localhost:8080` (frontend) and let the frontend's relative `/api` calls work — the frontend image is built with `VITE_API_URL=/api`, so no CORS is needed when served behind one domain. Example Caddy: ```caddy openstack.example.com { reverse_proxy localhost:8080 } ``` But note: Socket.IO also needs websocket upgrade; the bundled `nginx.conf` serves only static files. For single-domain production, proxy `/api` + `/socket.io` to the backend (see Option A Nginx snippet) and serve the built `frontend/dist` statically, or extend `frontend/nginx.conf` with upstream proxy blocks. ### Updates ```bash git pull docker compose up -d --build ``` ### Backup / restore (Compose) ```bash docker compose exec postgres pg_dump -U openstack openstack | gzip > backup.sql.gz gunzip -c backup.sql.gz | docker compose exec -T postgres psql -U openstack openstack ```