# Vultr + Oracle Cloud Free Tier

## Recommended: single container (1 GB RAM)

Oracle Always Free and Vultr $6 plans often have **1 GB RAM**. Use the all-in-one stack:

```bash
cp .env.example .env
# edit JWT_SECRET, POSTGRES_PASSWORD if using external DB
docker compose -f docker-compose.single.yml up -d --build
```

Open `http://YOUR_VM_IP:8080`

This uses root **`Dockerfile`** (builds web + runs API on port **8080**). No Postgres container — data in Docker volume `zendo_data`.

### Add swap (Oracle / small Vultr)

```bash
sudo fallocate -l 2G /swapfile
sudo chmod 600 /swapfile
sudo mkswap /swapfile
sudo swapon /swapfile
echo '/swapfile none swap sw 0 0' | sudo tee -a /etc/fstab
```

First build needs swap or **2 GB+ RAM** (Expo web compile is heavy).

## Split stack (2+ GB RAM)

If you have **4 GB+ RAM**, use full compose (API + nginx web + Postgres):

```bash
docker compose up -d --build
```

## Oracle Cloud specifics

1. Create **Ubuntu 22.04/24.04** VM (Ampere ARM or AMD — both work).
2. Open ingress: **TCP 8080** (or 80/443 if using reverse proxy).
3. Install Docker:

```bash
curl -fsSL https://get.docker.com | sh
sudo usermod -aG docker $USER
```

4. Upload **`zendo-full-deploy.zip`**, unzip, run compose command above.

## Vultr specifics

1. **Cloud Compute** → Ubuntu → install Docker (same as above).
2. Install Docker (see commands below) and run `docker compose -f docker-compose.single.yml up -d --build`.
3. Open firewall for port **8080**.

## External Postgres (optional)

On free tier, file DB in `/data` is fine for small traffic. For Postgres:

- Vultr Managed Database or Oracle Autonomous DB
- Set `DATABASE_URL` in `.env`
- Remove dependency on local postgres in compose (single container already has no postgres)

## Health check

```bash
curl http://localhost:8080/api/health
```

## Architecture (free tier)

```
Internet :8080
    └── zendo container
          ├── Bun API (backend/server.ts)
          ├── /api/trpc, /graphql, /webhooks/stripe
          └── /  → Expo web (dist/)
    └── volume zendo_data → zendo-store.json
```

## ARM (Oracle Ampere)

Images `oven/bun:1.2-alpine` and `node:22-alpine` support **arm64** — no changes needed.
