diff --git a/.gitignore b/.gitignore index c75f985..fea97b1 100644 --- a/.gitignore +++ b/.gitignore @@ -10,3 +10,6 @@ dist .logs/ .claude/ + +compose.yml + diff --git a/README.md b/README.md index bef4da6..4aaaf38 100644 --- a/README.md +++ b/README.md @@ -28,6 +28,8 @@ Your Claude Code clients generate encryption keys locally and use Happy Server a That said, Happy Server is open source and self-hostable if you prefer running your own infrastructure. The security model is identical whether you use our servers or your own. +**If you still want to self-host:** An easy way to self-host `happy-server` is by copying `compose.yml.tmpl` to `compose.yml` and adding a random `HANDY_MASTER_SECRET`. Run `docker compose up -d` afterward, and you'll have a running server accessible on port `3000`. For a more sophisticated setup with a reverse proxy and SSL, please refer to our [self-hosting guide](https://happy.engineering/docs/guides/self-hosting/). + ## License MIT - Use it, modify it, deploy it anywhere. \ No newline at end of file diff --git a/compose.yml.tmpl b/compose.yml.tmpl new file mode 100644 index 0000000..067adf9 --- /dev/null +++ b/compose.yml.tmpl @@ -0,0 +1,91 @@ +services: + happy-server: + build: . + ports: + - "3000:3000" + restart: unless-stopped + environment: + - NODE_ENV=production + - DATABASE_URL=postgresql://postgres:postgres@postgres:5432/happy-server + - REDIS_URL=redis://redis:6379 + - HANDY_MASTER_SECRET=your-seed-for-token-generation + - PORT=3000 + - S3_HOST=minio + - S3_PORT=9000 + - S3_USE_SSL=false + - S3_ACCESS_KEY=minioadmin + - S3_SECRET_KEY=minioadmin + - S3_BUCKET=happy + - S3_PUBLIC_URL=http://minio:9000/happy + depends_on: + postgres: + condition: service_healthy + minio: + condition: service_healthy + migrate: + condition: service_completed_successfully + + migrate: + build: . + command: yarn prisma migrate deploy + environment: + DATABASE_URL: postgresql://postgres:postgres@postgres:5432/happy-server + depends_on: + postgres: + condition: service_healthy + volumes: + - ./prisma:/app/prisma + + postgres: + image: postgres:15 + environment: + - POSTGRES_DB=happy-server + - POSTGRES_USER=postgres + - POSTGRES_PASSWORD=postgres + volumes: + - postgres_data:/var/lib/postgresql/data + healthcheck: + test: ["CMD-SHELL", "pg_isready -U postgres"] + interval: 10s + timeout: 5s + retries: 5 + + redis: + image: redis:7-alpine + volumes: + - redis_data:/data + + minio: + image: minio/minio + command: server /data --console-address ":9001" + # Include if you want to access the admin console + # ports: + # - "9001:9001" + environment: + - MINIO_ROOT_USER=minioadmin + - MINIO_ROOT_PASSWORD=minioadmin + volumes: + - minio_data:/data + healthcheck: + test: ["CMD", "curl", "-f", "http://localhost:9000/minio/health/live"] + interval: 30s + timeout: 20s + retries: 3 + + minio-init: + image: minio/mc + depends_on: + minio: + condition: service_healthy + entrypoint: > + /bin/sh -c " + mc alias set myminio http://minio:9000 minioadmin minioadmin; + mc mb myminio/happy || true; + mc anonymous set download myminio/happy; + exit 0; + " + +volumes: + postgres_data: + redis_data: + minio_data: