mirror of
https://github.com/bitbaum/loki.git
synced 2026-12-04 10:48:20 +01:00
First-run flow: - /setup page + /api/setup: creates first user with hashed password (Node crypto scrypt, no new deps). POST rejects if users already exist. - Landing page redirects to /setup when DB has no users - middleware.ts: protects app routes, passes public pages through Auth: - passwordHash column added to users schema (drizzle-kit push applied) - src/lib/password.ts: hashPassword/verifyPassword via Node scrypt - auth.ts Credentials: env var takes priority, falls back to DB hash so packaged installs work without LOCAL_AUTH_PASSWORD Multi-tenancy groundwork: - Replaced DEFAULT_USER_ID with getCurrentUserId() across all 12 API route files (people, subscriptions, events, goals, projects, commitments) Docker: - Dockerfile: multi-stage Node 22 alpine, standalone output - docker-compose.yml: postgres + migrate + app services - .dockerignore, .env.example with documented required vars - next.config.ts: output: standalone - package.json: added migrate script (drizzle-kit push) - tsconfig.json: scope to src/ only, exclude .next generated files Install: clone → cp .env.example .env.local → docker-compose up First visit → /setup → create account → sign in → done. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
46 lines
1.2 KiB
YAML
46 lines
1.2 KiB
YAML
services:
|
|
db:
|
|
image: postgres:17-alpine
|
|
restart: unless-stopped
|
|
environment:
|
|
POSTGRES_DB: cockpit
|
|
POSTGRES_USER: cockpit
|
|
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD:-changeme}
|
|
volumes:
|
|
- db_data:/var/lib/postgresql/data
|
|
healthcheck:
|
|
test: ["CMD-SHELL", "pg_isready -U cockpit"]
|
|
interval: 5s
|
|
timeout: 3s
|
|
retries: 10
|
|
|
|
migrate:
|
|
image: node:22-alpine
|
|
working_dir: /app
|
|
volumes:
|
|
- .:/app
|
|
environment:
|
|
DATABASE_URL: postgresql://cockpit:${POSTGRES_PASSWORD:-changeme}@db:5432/cockpit
|
|
command: sh -c "npm ci --prefer-offline && npx drizzle-kit push"
|
|
depends_on:
|
|
db:
|
|
condition: service_healthy
|
|
|
|
app:
|
|
build: .
|
|
restart: unless-stopped
|
|
ports:
|
|
- "${PORT:-3000}:3000"
|
|
environment:
|
|
DATABASE_URL: postgresql://cockpit:${POSTGRES_PASSWORD:-changeme}@db:5432/cockpit
|
|
AUTH_SECRET: ${AUTH_SECRET}
|
|
LOCAL_AUTH_PASSWORD: ${LOCAL_AUTH_PASSWORD:-}
|
|
GITHUB_CLIENT_ID: ${GITHUB_CLIENT_ID:-}
|
|
GITHUB_CLIENT_SECRET: ${GITHUB_CLIENT_SECRET:-}
|
|
depends_on:
|
|
migrate:
|
|
condition: service_completed_successfully
|
|
|
|
volumes:
|
|
db_data:
|