feat: add first-run admin setup

This commit is contained in:
i vib committed 2026-10-25 06:12:47 -07:00
1 parent dd2fc71867
commit 2aaa9335e3
16 files changed
+644 -152

No files matched your search

+4 -4
View File
@@ -11,9 +11,9 @@ services:
PORT: "3000"
DATASTACK_JWT_SECRET: "${SERVICE_REALBASE64_64_JWT:?Coolify must generate SERVICE_REALBASE64_64_JWT}"
DATASTACK_ADMIN_EMAIL: "${DATASTACK_ADMIN_EMAIL:?Set DATASTACK_ADMIN_EMAIL in .env}"
DATASTACK_ADMIN_PASSWORD: "${SERVICE_PASSWORDWITHSYMBOLS_64_ADMIN:?Coolify must generate SERVICE_PASSWORDWITHSYMBOLS_64_ADMIN}"
DATASTACK_ADMIN_SESSION_SECRET: "${SERVICE_REALBASE64_64_ADMINSESSION:?Coolify must generate SERVICE_REALBASE64_64_ADMINSESSION}"
DATABASE_URL: "postgresql://datastack:${SERVICE_PASSWORD_64_POSTGRES:?Coolify must generate SERVICE_PASSWORD_64_POSTGRES}@postgres:5432/datastack_db"
DATASTACK_ADMIN_SETUP_KEY: "${SERVICE_REALBASE64_64_ADMININSTALL:?Coolify must generate SERVICE_REALBASE64_64_ADMININSTALL}"
DATABASE_URL: "postgresql://datastack:${SERVICE_PASSWORD_64_POSTGRES:?Coolify must generate SERVICE_PASSWORD_64_POSTGRES}@postgres:5432/${SERVICE_HEX_32_DATABASENAME:?Coolify must generate SERVICE_HEX_32_DATABASENAME}"
restart: unless-stopped
healthcheck:
test:
@@ -91,12 +91,12 @@ services:
environment:
POSTGRES_USER: datastack
POSTGRES_PASSWORD: "${SERVICE_PASSWORD_64_POSTGRES:?Coolify must generate SERVICE_PASSWORD_64_POSTGRES}"
POSTGRES_DB: datastack_db
POSTGRES_DB: "${SERVICE_HEX_32_DATABASENAME:?Coolify must generate SERVICE_HEX_32_DATABASENAME}"
volumes:
- pgdata:/var/lib/postgresql/data
restart: unless-stopped
healthcheck:
test: ["CMD-SHELL", "pg_isready -U datastack -d datastack_db"]
test: ["CMD-SHELL", 'pg_isready -U datastack -d "$$POSTGRES_DB"']
interval: 10s
timeout: 5s
retries: 5
+6 -6
View File
@@ -8,16 +8,16 @@ Production container definitions for the split architecture:
- `ingestion`: Express + Socket.IO process on port 4000, running as a non-root user.
- `proxy`: Nginx reverse proxy on internal port 80. Coolify routes the public domain to this service; `/socket.io/` is forwarded to ingestion and other paths to web.
- `redis`: private Compose service reserved for the planned shared-buffer integration; current application code does not consume it.
- `postgres`: private Compose service reserved for metadata integration; current application code does not use Prisma at runtime. Collected events must remain in CSV files.
- `postgres`: private Compose service; the first-run admin setup/login helper stores the single bootstrap admin credential in `admin_users` using `pg`. Prisma-backed client/settings/audit metadata is not wired yet. Collected events must remain in CSV files.
## Coolify Compose Deployment
- Create a Git-based Docker Compose application from branch `main`.
- Set Base Directory to repository root `/` and Compose Location to `docker/docker-compose.yml`.
- Set `DATASTACK_ADMIN_EMAIL` in Coolify. The Compose definition uses Coolify-generated `SERVICE_PASSWORD_64_POSTGRES`, `SERVICE_REALBASE64_64_JWT`, `SERVICE_REALBASE64_64_ADMINSESSION`, and `SERVICE_PASSWORDWITHSYMBOLS_64_ADMIN`; it builds `DATABASE_URL` from the generated PostgreSQL password.
- Retrieve the generated `SERVICE_PASSWORDWITHSYMBOLS_64_ADMIN` from Coolify Environment Variables for the initial admin sign-in. JWT/session/admin secrets can be rotated in Coolify. A PostgreSQL password change also requires updating the database role in the existing persistent volume; never paste secrets into Git-tracked files.
- Set `DATASTACK_ADMIN_EMAIL` in Coolify. Compose uses generated `SERVICE_HEX_32_DATABASENAME`, `SERVICE_PASSWORD_64_POSTGRES`, `SERVICE_REALBASE64_64_JWT`, `SERVICE_REALBASE64_64_ADMINSESSION`, and `SERVICE_REALBASE64_64_ADMININSTALL`; `DATABASE_URL` is assembled from the generated DB name/password.
- On first visit, copy `SERVICE_REALBASE64_64_ADMININSTALL` from Coolify into `/vcon/setup`, confirm the `DATASTACK_ADMIN_EMAIL` configured in Coolify, choose the first admin password, and keep generated secrets in Coolify. The API enforces the configured email and setup closes after the first account is persisted.
- Add the public domain to service `proxy` at internal port `80`. Coolify manages proxy labels in its normal Compose mode; do not enable Raw Compose mode or add direct host port mappings.
- The `web`, `ingestion`, Redis, and PostgreSQL services are private on the Compose network. Only the proxy is exposed to Coolify's domain proxy.
- The `datastack-data` named volume persists ingestion CSVs; `pgdata` persists PostgreSQL files.
- The web container does not yet share/read `datastack-data`, and neither Redis nor PostgreSQL is wired into runtime code. Those are later roadmap phases, so cross-process reads and metadata durability are not established by these images.
- Health checks probe the web landing route, ingestion `/health`, proxy route, Redis ping, and PostgreSQL readiness. These checks do not establish application-level shared-storage readiness.
- The `datastack-data` named volume stores ingestion CSVs; `pgdata` stores PostgreSQL files and the bootstrap admin credential. Compose configures these named volumes for persistence; verify restart/redeploy behavior in the target Coolify runtime before relying on it. Do not delete the volumes or regenerate the DB name for an existing deployment. Back up before DB upgrades. DB password rotation requires changing the DB role as well as the Coolify value.
- The web container does not yet share/read `datastack-data`, and Redis is not wired into runtime code. Prisma-backed client/settings metadata remains future work; cross-process reads and general metadata durability are not established by these images.
- Health checks probe the web landing route, ingestion `/health`, proxy route, Redis ping, and PostgreSQL readiness using the generated `POSTGRES_DB` name. These checks do not establish application-level shared-storage readiness.