build: autogenerate Coolify environment secrets

Use Coolify-generated database/JWT/admin secrets, assemble DATABASE_URL from the generated DB password, and document the single manual admin email plus rotation requirements.
This commit is contained in:
i vib committed 2026-10-25 04:11:00 -07:00
1 parent e52e25e990
commit dd2fc71867
4 files changed
+19 -26

No files matched your search

+9 -17
View File
@@ -1,21 +1,13 @@
# GEMINI_API_KEY: Required for Gemini AI API calls.
# AI Studio automatically injects this at runtime from user secrets.
# Users configure this via the Secrets panel in the AI Studio UI.
# Optional settings for other hosting integrations; Coolify Compose does not require them.
GEMINI_API_KEY="MY_GEMINI_API_KEY"
# APP_URL: The URL where this applet is hosted.
# AI Studio automatically injects this at runtime with the Cloud Run service URL.
# Used for self-referential links, OAuth callbacks, and API endpoints.
APP_URL="MY_APP_URL"
# Production Compose requires unique values for these variables. Copy this file to `.env`
# and replace every blank value. Never commit `.env` or use generated placeholders in production.
DATASTACK_JWT_SECRET=
# Use the Compose service host `postgres`, database `datastack_db`, and user `datastack`.
DATABASE_URL=
POSTGRES_PASSWORD=
# Required to protect the admin console. Use a long, unique session secret (32+ characters).
# Coolify auto-generates these four secrets from docker-compose.yml magic variables:
# SERVICE_PASSWORD_64_POSTGRES
# SERVICE_REALBASE64_64_JWT
# SERVICE_REALBASE64_64_ADMINSESSION
# SERVICE_PASSWORDWITHSYMBOLS_64_ADMIN
# They are not entered here. JWT/session/admin secrets can be rotated in Coolify.
# PostgreSQL password rotation also requires changing the DB role password in the running database.
# The only required manual value for Coolify is the administrator's email:
DATASTACK_ADMIN_EMAIL=
DATASTACK_ADMIN_PASSWORD=
DATASTACK_ADMIN_SESSION_SECRET=
+2 -2
View File
@@ -54,10 +54,10 @@ The repository includes a Docker Compose stack for a Coolify Git-based Docker Co
1. In Coolify, add a Docker Compose application from `https://gitlab.com/ivibtools/datastack.git`, branch `main`.
2. Set Base Directory to `/` and Docker Compose Location to `docker/docker-compose.yml`.
3. Add the required variables in the Coolify application's Environment Variables: `DATASTACK_JWT_SECRET`, `DATASTACK_ADMIN_SESSION_SECRET`, `DATASTACK_ADMIN_EMAIL`, `DATASTACK_ADMIN_PASSWORD`, `DATABASE_URL`, and `POSTGRES_PASSWORD`. Use unique secrets; `DATABASE_URL` must use host `postgres`, database `datastack_db`, user `datastack`, and a password matching `POSTGRES_PASSWORD`.
3. Set `DATASTACK_ADMIN_EMAIL` in the application's Environment Variables. Coolify auto-generates the PostgreSQL password, JWT secret, admin session secret, and admin password from the `SERVICE_*` variables in Compose. No secret value needs to be pasted into the Compose file. The database URL is assembled internally using the generated PostgreSQL password. JWT/session/admin secrets can be rotated in Coolify; rotating the PostgreSQL password also requires updating the database role in the already-initialized database volume.
4. In Domains, add the public HTTPS domain to service `proxy` on internal port `80`. Do not expose `web`, `ingestion`, Redis, or PostgreSQL directly. Coolify supplies proxy labels for the selected service.
5. Deploy and check service health and runtime logs in Coolify.
The proxy sends `/` to Next.js and `/socket.io/` to the Socket.IO service over the private Compose network. The Settings page uses the current origin for a deployed WebSocket URL; local development on port 3000 still displays port 4000.
The `datastack-data` named volume persists CSVs written by ingestion. The web process does not yet read that volume; Redis and Prisma/PostgreSQL are not yet used by application code. Cross-process event visibility/shared storage remains Phase P4 work and metadata persistence remains Phase P5 work. Coolify deployment does not resolve those production-readiness gaps, and this stack has not yet been built or deployed on a Coolify VPS from this environment.
After deployment, copy the generated `SERVICE_PASSWORDWITHSYMBOLS_64_ADMIN` value from Coolify's Environment Variables when signing into the admin console. The `datastack-data` named volume persists CSVs written by ingestion. The web process does not yet read that volume; Redis and Prisma/PostgreSQL are not yet used by application code. Cross-process event visibility/shared storage remains Phase P4 work and metadata persistence remains Phase P5 work. Coolify deployment does not resolve those production-readiness gaps, and this stack has not yet been built or deployed on a Coolify VPS from this environment.
+6 -6
View File
@@ -9,11 +9,11 @@ services:
environment:
NODE_ENV: production
PORT: "3000"
DATASTACK_JWT_SECRET: "${DATASTACK_JWT_SECRET:?Set DATASTACK_JWT_SECRET in .env}"
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: "${DATASTACK_ADMIN_PASSWORD:?Set DATASTACK_ADMIN_PASSWORD in .env}"
DATASTACK_ADMIN_SESSION_SECRET: "${DATASTACK_ADMIN_SESSION_SECRET:?Set DATASTACK_ADMIN_SESSION_SECRET in .env}"
DATABASE_URL: "${DATABASE_URL:?Set DATABASE_URL 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"
restart: unless-stopped
healthcheck:
test:
@@ -40,7 +40,7 @@ services:
environment:
NODE_ENV: production
PORT_SOCKET: "4000"
DATASTACK_JWT_SECRET: "${DATASTACK_JWT_SECRET:?Set DATASTACK_JWT_SECRET in .env}"
DATASTACK_JWT_SECRET: "${SERVICE_REALBASE64_64_JWT:?Coolify must generate SERVICE_REALBASE64_64_JWT}"
restart: unless-stopped
healthcheck:
test:
@@ -90,7 +90,7 @@ services:
image: postgres:16-alpine
environment:
POSTGRES_USER: datastack
POSTGRES_PASSWORD: "${POSTGRES_PASSWORD:?Set POSTGRES_PASSWORD in .env}"
POSTGRES_PASSWORD: "${SERVICE_PASSWORD_64_POSTGRES:?Coolify must generate SERVICE_PASSWORD_64_POSTGRES}"
POSTGRES_DB: datastack_db
volumes:
- pgdata:/var/lib/postgresql/data
+2 -1
View File
@@ -14,7 +14,8 @@ Production container definitions for the split architecture:
- 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 every required interpolated variable in Coolify: JWT/admin secrets and credentials, `DATABASE_URL`, and `POSTGRES_PASSWORD`.
- 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.
- 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.