Files
captable/SELF-HOSTING.md
zeekay a802f619cd Serve every route under /v1
next-auth moves to /v1/iam, tRPC to /v1/trpc and the Hono REST API to
/v1/companies, /v1/schema, /v1/swagger and /v1/docs. HIP-0111: no /api/
prefix. The /api copies of the REST handler and docs page, and the empty
apiKeys handler, are deleted.

next-auth v4 takes its server mount from the path of NEXTAUTH_URL, so
env.js refuses anything but <origin>/v1/iam; SessionProvider takes the
same AUTH_BASE_PATH. src/routes.test.ts fails if src/app/api returns or
any source names an /api/ path, and hanzo.yml runs it before the image.

Claude-Session: https://claude.ai/code/session_01TUxvfuta1Z44KVNYuAz71F
2026-09-24 15:05:00 -07:00

114 lines
3.3 KiB
Markdown

<h2 id="hosting">🚀 Self hosting</h2>
Hanzo Captable is an open-source project that you can host on your own server. This gives you full control over your data.
If you like to self-host Hanzo Captable, please schedule a call with us, and we will help you set up your own instance.
<a href="https://captable.hanzo.ai/schedule/"><img alt="Book us" src="https://cal.com/book-with-cal-dark.svg" /></a>
- **Prerequisites**:
- Docker
- Postgres database (RDS, Cloud SQL, Supabase, Neon etc.)
- SMTP provider (Resend, AWS SES, Mailgun, Sendgrid etc.)
- S3 Compatible storage (AWS S3, R2, Minio, Backblaze etc.)
- **Official Docker Images**:
- <a href="https://hub.docker.com/r/hanzoai/captable" target="_blank">Docker hub</a>
<!-- - <a href="https://github.com/hanzoai/captable/pkgs/container/captable" target="_blank">Github registry</a> -->
- **Environment Variables**:\
Following envrionment variables are required
```bash
NODE_ENV="production"
DATABASE_URL="postgres://user:password@host:port/dbname"
NEXTAUTH_SECRET="xxx" # Generated by `openssl rand -base64 32`
NEXTAUTH_URL="https://your-domain.com/v1/iam" # where next-auth is mounted
NEXT_PUBLIC_BASE_URL="https://your-domain.com"
# Hanzo IAM application: sign-in, and the identity that sends email through
# Hanzo notify with the org's email provider
IAM_URL="https://hanzo.id"
IAM_CLIENT_ID="xxx"
IAM_CLIENT_SECRET="xxx"
# File uplod environment variables
UPLOAD_REGION="us-west-1" # auto when using Cloudflare R2
UPLOAD_ENDPOINT="https://xxx.r2.cloudflarestorage.com"
UPLOAD_ACCESS_KEY_ID="xxx"
UPLOAD_SECRET_ACCESS_KEY="xxx"
UPLOAD_BUCKET_PUBLIC="public-bucket-name"
UPLOAD_BUCKET_PRIVATE="private-bucket-name"
```
Following environment variables are optional
```bash
# If you are using custom domain, especially with Cloudflare R2, AWAS S3 with custom domain.
NEXT_PUBLIC_UPLOAD_DOMAIN="https://custom.your-domain.com"
```
- **Run the docker container**:
```bash
docker run -d \
-e NODE_ENV="replace" \
-e DATABASE_URL="replace" \
-e NEXTAUTH_SECRET="replace" \
-e NEXTAUTH_URL="replace" \
-e NEXT_PUBLIC_BASE_URL="replace" \
-e IAM_URL="replace" \
-e IAM_CLIENT_ID="replace" \
-e IAM_CLIENT_SECRET="replace" \
-e UPLOAD_REGION="replace" \
-e UPLOAD_ENDPOINT="replace" \
-e NEXT_PUBLIC_UPLOAD_DOMAIN="replace" \
-e UPLOAD_ACCESS_KEY_ID="replace" \
-e UPLOAD_SECRET_ACCESS_KEY="replace" \
-e UPLOAD_BUCKET_PUBLIC="replace" \
-e UPLOAD_BUCKET_PRIVATE="replace" \
-p 3000:3000 \
hanzoai/captable
```
- **Setup CORS for file uploads**:\
Some of the services including Cloudflare R2 may require you to setup CORS for file uploads.\
> Here is an sample CORS configuration for Cloudflare R2.
```json
[
{
"AllowedOrigins": [
"https://your-domain.com"
],
"AllowedMethods": [
"HEAD",
"GET",
"POST",
"PUT",
"DELETE"
],
"AllowedHeaders": [
"*"
]
}
]
```
- **Run database migrations**:
```bash
docker exec -it <container_id> npx prisma migrate deploy
```
<!-- Ready -->
- **Access the application**:\
Open your browser and navigate to `https://your-domain.com`
- **Questions?**\
If you have any questions, please schedule a call with us, and we will help you set up your own instance.
<a href="https://captable.hanzo.ai/schedule/"><img alt="Book us" src="https://cal.com/book-with-cal-dark.svg" /></a>