Developer Environment Setup
⚙️ Prerequisites
✅ Enable Corepack and Install Yarn 4
corepack enable
corepack prepare yarn@latest --activate
🐳 Install Docker
Follow the official guide: Docker Installation Docs
🧪 Development Environment
In the /app directory, run the following commands to start development containers:
# Build and start development containers
docker compose build dev --no-cache
docker compose up -d
# Push database schema
docker exec -it takhi-dev npx drizzle-kit push
Backing up and restoring database
# on dev machine
docker exec db pg_dump -U takhi -d takhi -F c > takhi_backup.dump
# send to prod vm
scp takhi_backup.dump takhi:/home/zhao/workspace/takhi/app/drizzle/takhi_backup.dump
# restore on prod
cd /home/zhao/workspace/takhi/app/drizzle
cat takhi_backup.dump | docker exec -i db pg_restore -U takhi -d takhi
docker exec -i db psql -U takhi -d takhi < cron_jobs.sql
Redis
docker exec -it takhi-redis redis-cli
keys *
Open http://localhost:3000 with your browser to see the result.
This project uses next/font to automatically optimize and load Inter, a custom Google Font.
Stripe
Using stripe cli
docker run -it --entrypoint /bin/sh stripe/stripe-cli:latest
stripe login
stripe listen --skip-verify --events payment_intent.created,customer.created,payment_intent.succeeded,checkout.session.completed,payment_intent.payment_failed --forward-to localhost:3000/api/checkout/stripe-webhook
🚀 Production Build & Deployment
📦 Build and Push Docker Images
# Login to GitHub Container Registry
echo $CR_PAT | docker login ghcr.io -u <username> --password-stdin
# Build and push application image
docker compose -f compose.prod.yml build takhi --no-cache
docker push ghcr.io/agentzhao/takhi:latest
# Build and push PostgreSQL image
docker compose -f compose.prod.yml build postgres --no-cache
docker push ghcr.io/agentzhao/postgres-16
🌐 Deploy on Server
# Pull and start containers on the server
docker compose -f compose.prod.yml up -d
# Initialize database, or any migrations/updates
docker exec -i db psql -d takhi -U takhi < 0000_init.sql
🐞 Debugging & Utilities
🔧 Troubleshooting Docker Builds
docker compose --progress plain build dev --no-cache
🐘 PostgreSQL CLI Access
Access the docker container first
psql -h db -U takhi -d takhi
📋 Updating Database Schema
# Push schema changes
docker exec -it takhi-dev yarn drizzle-kit push --verbose
# Generate new migration
docker exec -it takhi-dev yarn drizzle-kit generate --name=init
# Example query inside psql
SELECT * FROM public.user;
📂 Copy yarn.lock from Container
docker cp takhi-dev:/app/yarn.lock ./yarn.lock