# Coolify Deployment Guide This project is ready for deployment on Coolify. ## Prerequisites 1. Coolify instance running 2. GitHub repository with this code 3. PostgreSQL database ## Deployment Steps ### Option 1: Single Docker Compose App 1. Create a new Docker Compose application in Coolify 2. Connect your GitHub repository 3. Select the `docker-compose.yml` file in the root 4. Configure environment variables: ``` DATABASE_URL=postgres://postgres:your_password@postgres:5432/fiscal POSTGRES_USER=postgres POSTGRES_PASSWORD=your_password POSTGRES_DB=fiscal PORT=3001 BETTER_AUTH_SECRET=your-random-long-secret BETTER_AUTH_BASE_URL=https://api.your-fiscal-domain.com JWT_SECRET=your-jwt-secret-key-min-32-characters GITHUB_ID=your-github-oauth-client-id GITHUB_SECRET=your-github-oauth-client-secret GOOGLE_ID=your-google-oauth-client-id GOOGLE_SECRET=your-google-oauth-client-secret NEXT_PUBLIC_API_URL=https://your-fiscal-domain.com ``` 5. Deploy ### Option 2: Separate Applications #### Backend 1. Create a new application in Coolify 2. Source: GitHub 3. Branch: `main` 4. Build Context: `/backend` 5. Build Pack: `Dockerfile` 6. Environment Variables: ``` DATABASE_URL=postgres://... PORT=3001 ``` 7. Deploy #### Frontend 1. Create a new application in Coolify 2. Source: GitHub 3. Branch: `main` 4. Build Context: `/frontend` 5. Build Pack: `Dockerfile` 6. Environment Variables: ``` NEXT_PUBLIC_API_URL=https://your-backend-domain.com ``` 7. Deploy ## Environment Variables ### Backend - `DATABASE_URL` - PostgreSQL connection string - `PORT` - Server port (default: 3001) - `NODE_ENV` - Environment (development/production) - `BETTER_AUTH_SECRET` - Required in production; use a long random secret - `BETTER_AUTH_BASE_URL` - Public backend URL used for auth callbacks ### Frontend - `NEXT_PUBLIC_API_URL` - Backend API URL `NEXT_PUBLIC_API_URL` is used at image build time in the frontend Docker build. Set it in Coolify before deploying so the generated client bundle points to the correct backend URL. ## Database Setup The application will automatically create the database schema on startup. To manually run migrations: ```bash docker exec -it bun run db:migrate ``` ## Monitoring Once deployed, add the application to OpenClaw's monitoring: 1. Add to `/data/workspace/memory/coolify-integration.md` 2. Set up Discord alerts for critical issues 3. Configure cron jobs for health checks ## Troubleshooting ### Database Connection Failed - Check DATABASE_URL is correct - Ensure PostgreSQL container is running - Verify network connectivity ### Frontend Can't Connect to Backend - Verify NEXT_PUBLIC_API_URL points to backend - Check CORS settings in backend - Ensure both containers are on same network ### Cron Jobs Not Running - Check Elysia cron configuration - Verify timezone settings - Check logs for errors