Deployment
This guide covers deploying the Cosailor Template to production environments, including Cloud Run deployment and Docker containerization.
Prerequisites
Before deploying, ensure you have:
- Environment variables properly configured
- Database set up and migrated
- OAuth providers configured
- Docker installed (for local Docker builds)
Environment Variables Setup
Core API Environment Variables
Create /apps/core-api/.env with production values:
DATABASE_URL=postgresql://username:password@host:port/database_name
Web Frontend Environment Variables
Create /apps/web/.env with production values:
AUTH_GOOGLE_ID=<production-google-oauth-client-id>
AUTH_GOOGLE_SECRET=<production-google-oauth-client-secret>
AUTH_SECRET=<random-production-string>
AUTH_TRUST_HOST=true
AUTH_URL=http://<deployed-url>/api/auth
Package Installation
Install pnpm and Dependencies
-
Install pnpm (if not already installed):
curl -fsSL https://get.pnpm.io/install.sh | sh - -
Install all project dependencies:
pnpm install -
Install Python dependencies (required for running migrations):
pip install -r apps/core-api/requirements.txt
Database Setup
Run the database migrations to set up production tables:
pnpm run migrate
This command will:
- Connect to your production database
- Run all Alembic migrations
- Set up the required database schema
Docker Build Process
Building Docker Images
Web Frontend
docker build -t cosailor-web -f apps/web/Dockerfile .
Core API
docker build -t cosailor-core-api -f apps/core-api/Dockerfile apps/core-api/