Skip to content

Docker Setup

Flowstate uses Docker Compose for local development, providing a consistent environment across all team members. All services run in containers, managed via just commands that wrap Docker Compose with secrets injection.

Before starting, ensure you have:

  1. Docker Desktop (or Docker Engine + Docker Compose)

  2. Secrets management tooling — required to inject development secrets at runtime. Contact your administrator for setup instructions.

  3. Just (command runner)

  4. Node.js 22 and pnpm 10 (for local tooling)

    • Install: brew install node@22 pnpm (macOS)
Terminal window
# Clone the repository
git clone https://github.com/your-org/flowstate-canvas.git
cd flowstate-canvas
# One-command setup (checks prereqs, installs deps, starts services)
just setup
# Or manually:
pnpm install
just up
just db-push
# View logs
just logs
# Stop all services
just down

After running just up, the services will be available at the URLs configured for your environment. See your administrator for the local service addresses.

Docker Compose runs the following services:

ServiceDescriptionImage
backendExpress.js REST API + RPC GatewayNode.js 22
webAstro frontend (main app)Node.js 22
adminAstro admin dashboardNode.js 22
mongodbMongoDB 7 replica setmongo:7
mongodb-initMongoDB replica set initializermongo:7
redisRedis 7 cache and pub/subredis:7-alpine
minioS3-compatible object storageminio/minio
web ──────┐
admin ────┼──> backend ──┬──> mongodb
│ └──> redis
└──> minio (for uploads)

All services start automatically in the correct order based on depends_on configuration.

The justfile provides convenient commands for managing the Docker environment. Always use just commands instead of running docker compose directly to ensure secrets are injected properly.

CommandDescription
just setupFirst-time setup (prereqs + install + start + schema)
just upStart all services (detached mode)
just downStop all services
just restartRestart all services
just stopStop services without removing containers
just teardownComplete teardown (Docker + host deps + caches + artifacts)
CommandDescription
just logsView logs from all services (follow mode)
just logs-backendView backend logs only
just logs-webView web logs only
just logs-adminView admin logs only
just logs-dbView MongoDB logs

Example:

Terminal window
# View all logs
just logs
# View backend logs only
just logs-backend
CommandDescription
just rebuildRebuild all images without cache
just buildBuild images (uses cache)

When to rebuild:

  • After changing Dockerfile or docker-compose.yml
  • After updating dependencies in package.json
  • When experiencing unexplained errors (cache issues)
CommandDescription
just shell-backendOpen shell in backend container
just shell-webOpen shell in web container
just shell-adminOpen shell in admin container
just shell-dbOpen MongoDB shell (mongosh)
just redis-cliOpen Redis CLI

Example:

Terminal window
# Shell into backend container
just shell-backend
# Inside container, run commands
pnpm tsc --noEmit
pnpm build
exit
CommandDescription
just db-generateGenerate Prisma client
just db-pushPush Prisma schema to MongoDB
just db-seedSeed demo data
just db-studioOpen Prisma Studio
just db-resetReset database (drops all data!)

Example workflow:

Terminal window
# After modifying prisma/schema.prisma
just db-generate # Regenerate Prisma client
just db-push # Apply schema changes to MongoDB
just db-seed # Seed demo data (optional)
CommandDescription
just typecheckRun TypeScript checks on all apps
just typecheck-backendCheck backend only
just typecheck-webCheck web only
CommandDescription
just desktopStart Electron desktop app (dev mode)
just desktop-restartRestart desktop app
just desktop-stopStop desktop app

The desktop app runs locally (not in Docker) because it needs GPU and display access.

Prisma requires MongoDB to run as a replica set (even for single-node development). The mongodb-init service automatically initializes the replica set on first startup.

Initialization process:

  1. mongodb service starts
  2. mongodb-init waits for MongoDB to be ready
  3. mongodb-init runs rs.initiate() to create replica set
  4. mongodb-init exits (one-time setup)
  5. Backend connects to replica set

Troubleshooting:

If you see “not master and slaveOk=false” errors:

Terminal window
# Restart MongoDB and re-initialize
just down
docker volume rm flowstatecanvas_mongodb_data
just up

Environment variables are injected via your secrets management solution and never written to disk.

The project uses a template file that maps environment variable names to secret references. When you run just up, the secrets tool resolves those references and injects real values as environment variables. Docker Compose picks them up via ${VAR} substitution.

Never run docker compose directly — it won’t have access to secrets.

All services include health checks to ensure they’re ready before dependent services start:

healthcheck:
test: ['CMD', 'curl', '-f', 'http://localhost:<port>/health']
interval: 10s
timeout: 5s
retries: 5
start_period: 30s

Check service health:

Terminal window
docker compose ps

Output shows health status:

NAME STATUS
backend Up (healthy)
web Up (healthy)
mongodb Up (healthy)
redis Up (healthy)

All services support hot reload for rapid development:

ServiceHot Reload Method
Backendtsx watch (restarts on file changes)
WebAstro dev server (HMR)
AdminAstro dev server (HMR)

Changes to source files are immediately reflected in running containers without a rebuild.

Docker Compose creates a bridge network where services communicate using service names as hostnames:

backend -> mongodb:27017
backend -> redis:6379
web -> backend:3000 (via SERVER_API_URL)

Important: Use service names (not localhost) in container-to-container communication.

Data is persisted in Docker volumes:

VolumePurpose
mongodb_dataMongoDB database files
redis_dataRedis persistence (AOF)
minio_dataMinIO object storage

Volumes survive container restarts but are deleted when running docker compose down -v.

Backup data:

Terminal window
# Backup MongoDB
docker compose exec mongodb mongodump --out /dump
docker compose cp mongodb:/dump ./backup
# Backup MinIO
docker compose exec minio mc mirror /data ./backup/minio
Terminal window
# Check logs for errors
just logs
# Rebuild without cache
just rebuild
# Reset everything
just down
docker volume prune
just up

If ports are already in use, identify the conflicting process and stop it, or update the port mapping in docker-compose.yml.

Terminal window
# Check MongoDB is running
docker compose ps mongodb
# Check replica set status
just shell-db
rs.status()
exit
# Re-initialize replica set
just down
docker volume rm flowstatecanvas_mongodb_data
just up

Verify your secrets management tooling is correctly configured. Contact your administrator if you do not have access to the development vault.

Terminal window
# Remove unused images and volumes
docker system prune -a --volumes
# Check disk usage
docker system df

Increase Docker Desktop resources: Docker Desktop → Settings → Resources. Recommended: 4 CPUs, 8GB RAM.

  1. Always use just commands — Never run docker compose directly
  2. Check logs first — Most issues are visible in logs
  3. Rebuild after dependency changes — Run just rebuild after updating package.json
  4. Use health checks — Wait for services to be healthy before testing
  5. Clean up regularly — Run docker system prune weekly to free disk space
  6. Monitor resource usage — Check Docker Desktop dashboard for CPU/memory usage
  7. Backup data before resetsjust db-reset is destructive
  8. Test in containers — Don’t rely on local Node.js for testing
  9. Keep Docker Desktop updated — Latest version has performance improvements

Development and production Docker setups differ:

AspectDevelopmentProduction
ImagesBuilt locallyPre-built on container registry
SecretsSecrets management toolingEnvironment variables / vault
VolumesSource code mountedNo mounts (baked into image)
Hot reloadEnabledDisabled
PortsAll exposedOnly public ports exposed
NetworkingBridge networkOverlay network (Swarm/K8s)
LoggingstdoutCentralized logging (Loki, etc.)
Health checksBasicComprehensive with alerts

See Production Deployment for production setup details.