# ────────────────────────────────────────────────────────── # Openship — Docker Compose # # cp .env.example .env # then edit # docker compose up -d --build # # ONE set of services. The MODE is decided entirely by .env — there are no # profiles and no per-mode service variants: # • Default (users): self-hosted → CLOUD_MODE=false (the .env.example default) # • SaaS (our env): CLOUD_MODE=true + OPENSHIP_TARGET=cloud-saas # + Oblien / GitHub App / secrets # # Services: # • postgres → private :5432 (storage) # • redis → private :6379 (queue + cache + rate-limit) # • api → :4000 # • dashboard→ :3001 # • web → :3000 # # The API + dashboard bind fixed internal ports via PORT (the API honors PORT # regardless of OPENSHIP_TARGET); a reverse proxy maps the public domains to # them. postgres/redis are internal-only. The API auto-migrates Postgres on boot. # ────────────────────────────────────────────────────────── services: # ─── Database (storage, private) ────────────────────── postgres: image: postgres:16-alpine restart: unless-stopped environment: POSTGRES_USER: ${POSTGRES_USER:-openship} POSTGRES_PASSWORD: ${POSTGRES_PASSWORD:-openship} POSTGRES_DB: ${POSTGRES_DB:-openship} # PRIVATE: not published to the host. api reaches it at postgres:5432. expose: - "5432" volumes: - postgres_data:/var/lib/postgresql/data healthcheck: test: ["CMD-SHELL", "pg_isready -U ${POSTGRES_USER:-openship} -d ${POSTGRES_DB:-openship}"] interval: 5s timeout: 3s retries: 12 # ─── Cache / Queue / Rate-limit (private) ───────────── redis: image: redis:7-alpine restart: unless-stopped command: ["redis-server", "--appendonly", "yes"] # PRIVATE: not published to the host. api reaches it at redis:6379. expose: - "6379" volumes: - redis_data:/data healthcheck: test: ["CMD", "redis-cli", "ping"] interval: 5s timeout: 3s retries: 12 # ─── API (control plane) ────────────────────────────── api: build: context: . dockerfile: apps/api/Dockerfile restart: unless-stopped ports: - "4000:4000" # Mode + secrets (CLOUD_MODE, DEPLOY_MODE, OPENSHIP_TARGET, Oblien, GitHub # App, auth secrets, …) all come from .env. The values below OVERRIDE it # with the fixed internal port + in-cluster service DNS (compose # `environment` wins over `env_file`). env_file: - .env environment: NODE_ENV: production PORT: "4000" DATABASE_URL: postgresql://${POSTGRES_USER:-openship}:${POSTGRES_PASSWORD:-openship}@postgres:5432/${POSTGRES_DB:-openship} REDIS_URL: redis://redis:6379 depends_on: postgres: condition: service_healthy redis: condition: service_healthy healthcheck: test: ["CMD-SHELL", "bun -e \"fetch('http://127.0.0.1:4000/api/health').then(r=>process.exit(r.ok?0:1)).catch(()=>process.exit(1))\""] interval: 10s timeout: 5s retries: 12 start_period: 40s # ─── Dashboard (app UI) ─────────────────────────────── dashboard: build: context: . dockerfile: apps/dashboard/Dockerfile restart: unless-stopped ports: - "3001:3001" env_file: - .env environment: NODE_ENV: production PORT: "3001" depends_on: api: condition: service_healthy # ─── Web / Landing ──────────────────────────────────── web: build: context: . dockerfile: apps/web/Dockerfile restart: unless-stopped ports: - "3000:3000" environment: NODE_ENV: production PORT: "3000" volumes: postgres_data: redis_data: