This guide provides step-by-step instructions for setting up the PSA system using Docker Compose, supporting both Community Edition (CE) and Enterprise Edition (EE).
- Docker Engine 24.0.0 or later
- Docker Compose v2.20.0 or later
- Git
- Text editor for configuration files
- Clone the repository:
git clone https://github.com/nine-minds/alga-psa.git
cd alga-psa
- Create required directories:
mkdir -p secrets
- Create secret files in the
secrets/
directory:
Database Secrets:
# Admin user (postgres) - for database administration
echo "your-secure-admin-password" > secrets/postgres_password
# Application user (app_user) - for RLS-controlled access
echo "your-secure-app-password" > secrets/db_password_server
# Hocuspocus service
echo "your-secure-hocuspocus-password" > secrets/db_password_hocuspocus
Redis Secret:
echo "your-secure-password" > secrets/redis_password
Authentication Secret:
# Authentication key for password hashing
echo "your-32-char-min-key" > secrets/alga_auth_key
Security Secrets:
echo "your-32-char-min-key" > secrets/crypto_key
echo "your-32-char-min-key" > secrets/token_secret_key
echo "your-32-char-min-key" > secrets/nextauth_secret
Email & OAuth Secrets:
echo "your-email-password" > secrets/email_password
echo "your-client-id" > secrets/google_oauth_client_id
echo "your-client-secret" > secrets/google_oauth_client_secret
- Set proper permissions:
chmod 600 secrets/*
- Copy the appropriate environment template:
cp .env.example server/.env
- Edit the environment file and configure required values:
Required Variables:
# Database Configuration
DB_TYPE=postgres # Must be "postgres"
DB_USER_ADMIN=postgres # Admin user for database operations
# Logging Configuration
LOG_LEVEL=INFO # One of: SYSTEM, TRACE, DEBUG, INFO, WARNING, ERROR, CRITICAL
LOG_IS_FORMAT_JSON=false
LOG_IS_FULL_DETAILS=false
# Email Configuration
EMAIL_ENABLE=false # Set to "true" to enable email notifications
[email protected] # Must be valid email
EMAIL_HOST=smtp.gmail.com # SMTP server hostname
EMAIL_PORT=587 # SMTP port (587 for TLS, 465 for SSL)
[email protected] # SMTP username
# Authentication Configuration
NEXTAUTH_URL=http://localhost:3000 # Must be valid URL
NEXTAUTH_SESSION_EXPIRES=86400 # Must be > 0
Optional Variables:
# Hocuspocus Configuration
REQUIRE_HOCUSPOCUS=false # Set to "true" to require hocuspocus service
Note: The system performs validation of these environment variables at startup. Missing or invalid values will prevent the system from starting.
The system uses a two-user database authentication model for security:
-
Admin User:
- Username: postgres
- Password: Stored in postgres_password secret
- Purpose: Database administration, setup, migrations
- Access: Full database access
- Used by: Setup scripts, migrations, administrative tasks
-
Application User:
- Username: app_user
- Password: Stored in db_password_server secret
- Purpose: Application database access
- Access: Limited by Row Level Security (RLS) policies
- Used by: Application services, regular operations
This separation ensures:
- Principle of least privilege
- Data access control through RLS
- Clear separation of administrative and application operations
- For development:
docker compose -f docker-compose.base.yaml -f docker-compose.ce.yaml up
- For production:
docker compose -f docker-compose.base.yaml -f docker-compose.ce.yaml -f docker-compose.prod.yaml up -d
- For development:
docker compose -f docker-compose.base.yaml -f docker-compose.ee.yaml up
- For production:
docker compose -f docker-compose.base.yaml -f docker-compose.ee.yaml -f docker-compose.prod.yaml up -d
The entrypoint scripts will automatically:
- Validate environment variables
- Check dependencies
- Initialize database with both users
- Set up RLS policies
- Run database migrations
- Seed initial data (in development)
- Start services
You can monitor the initialization process through Docker logs:
docker compose logs -f
After successful initialization, the server logs will display a sample username and password that can be used for initial access:
docker compose logs -f
- Check service health:
docker compose ps
- Access the application:
- Development: http://localhost:3000
- Production: https://your-domain.com
- Verify logs for any errors:
docker compose logs [service-name]
- Check all required variables are set
- Verify DB_TYPE is set to "postgres"
- Ensure LOG_LEVEL is a valid value
- Verify email addresses are valid
- Check numeric values are > 0
- Verify URLs are valid
- Verify secret files exist and have correct permissions
- Check database host/port configuration
- Ensure PostgreSQL container is running
- Verify postgres_password for admin operations
- Verify db_password_server for application access
- Check RLS policies if access is denied
- Verify redis_password secret exists
- Check redis host/port configuration
- Ensure Redis container is running
- Verify alga_auth_key secret exists and is properly configured
- Ensure authentication key is at least 32 characters long
- Check permissions on alga_auth_key secret file
- Check REQUIRE_HOCUSPOCUS setting
- Verify service availability if required
- Check connection timeout settings
- Verify database access
- Check service logs for specific errors
- Verify all required secrets exist
- Ensure correct environment variables are set
- Verify database users and permissions
✓ All secrets created with secure values ✓ Secret files have restricted permissions (600) ✓ Environment files configured without sensitive data ✓ Production environment uses HTTPS ✓ Database passwords are strong and unique ✓ Redis password is configured ✓ Authentication key (alga_auth_key) is properly configured ✓ Encryption keys are at least 32 characters ✓ RLS policies properly configured ✓ Database users have appropriate permissions ✓ Environment variables properly validated
- Configure email notifications:
- Set environment variables:
EMAIL_ENABLE=true EMAIL_HOST=smtp.example.com EMAIL_PORT=587 # or 465 for SSL [email protected] EMAIL_PASSWORD=your-secure-password [email protected]
- Run migrations to set up notification tables:
cd server && npx knex migrate:latest
- Seed default templates and categories:
cd server && npx knex seed:run
- Features available after setup:
- System-wide default templates
- Tenant-specific template customization
- User notification preferences
- Rate limiting and audit logging
- Categories: Tickets, Invoices, Projects, Time Entries
- Set environment variables:
- Set up OAuth if using Google authentication
- Configure SSL/TLS for production
- Set up backup procedures
- Configure monitoring and logging
- Review security settings
- Review and test RLS policies
When upgrading from a previous version:
- Backup all data:
docker compose exec postgres pg_dump -U postgres server > backup.sql
- Update the repository:
git pull origin main
- Review changes in:
- Docker Compose files
- Environment variables
- Secret requirements
- Database schema
- RLS policies
- Protocol Buffer definitions (EE only)
-
Update configurations as needed
-
Rebuild and restart:
docker compose down
docker compose up -d --build