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.
Prerequisites
Section titled “Prerequisites”Before starting, ensure you have:
-
Docker Desktop (or Docker Engine + Docker Compose)
- macOS: Docker Desktop for Mac
- Windows: Docker Desktop for Windows
- Linux: Docker Engine + Docker Compose
-
Secrets management tooling — required to inject development secrets at runtime. Contact your administrator for setup instructions.
-
Just (command runner)
- Install:
brew install just(macOS) or other methods
- Install:
-
Node.js 22 and pnpm 10 (for local tooling)
- Install:
brew install node@22 pnpm(macOS)
- Install:
Quick Start
Section titled “Quick Start”# Clone the repositorygit clone https://github.com/your-org/flowstate-canvas.gitcd flowstate-canvas
# One-command setup (checks prereqs, installs deps, starts services)just setup
# Or manually:pnpm installjust upjust db-push
# View logsjust logs
# Stop all servicesjust downAfter running just up, the services will be available at the URLs configured for your environment. See your administrator for the local service addresses.
Services
Section titled “Services”Docker Compose runs the following services:
| Service | Description | Image |
|---|---|---|
backend | Express.js REST API + RPC Gateway | Node.js 22 |
web | Astro frontend (main app) | Node.js 22 |
admin | Astro admin dashboard | Node.js 22 |
mongodb | MongoDB 7 replica set | mongo:7 |
mongodb-init | MongoDB replica set initializer | mongo:7 |
redis | Redis 7 cache and pub/sub | redis:7-alpine |
minio | S3-compatible object storage | minio/minio |
Service Dependencies
Section titled “Service Dependencies”web ──────┐admin ────┼──> backend ──┬──> mongodb │ └──> redis │ └──> minio (for uploads)All services start automatically in the correct order based on depends_on configuration.
Just Commands
Section titled “Just Commands”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.
Starting and Stopping
Section titled “Starting and Stopping”| Command | Description |
|---|---|
just setup | First-time setup (prereqs + install + start + schema) |
just up | Start all services (detached mode) |
just down | Stop all services |
just restart | Restart all services |
just stop | Stop services without removing containers |
just teardown | Complete teardown (Docker + host deps + caches + artifacts) |
| Command | Description |
|---|---|
just logs | View logs from all services (follow mode) |
just logs-backend | View backend logs only |
just logs-web | View web logs only |
just logs-admin | View admin logs only |
just logs-db | View MongoDB logs |
Example:
# View all logsjust logs
# View backend logs onlyjust logs-backendBuilding
Section titled “Building”| Command | Description |
|---|---|
just rebuild | Rebuild all images without cache |
just build | Build images (uses cache) |
When to rebuild:
- After changing
Dockerfileordocker-compose.yml - After updating dependencies in
package.json - When experiencing unexplained errors (cache issues)
Shell Access
Section titled “Shell Access”| Command | Description |
|---|---|
just shell-backend | Open shell in backend container |
just shell-web | Open shell in web container |
just shell-admin | Open shell in admin container |
just shell-db | Open MongoDB shell (mongosh) |
just redis-cli | Open Redis CLI |
Example:
# Shell into backend containerjust shell-backend
# Inside container, run commandspnpm tsc --noEmitpnpm buildexitDatabase Commands
Section titled “Database Commands”| Command | Description |
|---|---|
just db-generate | Generate Prisma client |
just db-push | Push Prisma schema to MongoDB |
just db-seed | Seed demo data |
just db-studio | Open Prisma Studio |
just db-reset | Reset database (drops all data!) |
Example workflow:
# After modifying prisma/schema.prismajust db-generate # Regenerate Prisma clientjust db-push # Apply schema changes to MongoDBjust db-seed # Seed demo data (optional)Type Checking
Section titled “Type Checking”| Command | Description |
|---|---|
just typecheck | Run TypeScript checks on all apps |
just typecheck-backend | Check backend only |
just typecheck-web | Check web only |
Desktop App
Section titled “Desktop App”| Command | Description |
|---|---|
just desktop | Start Electron desktop app (dev mode) |
just desktop-restart | Restart desktop app |
just desktop-stop | Stop desktop app |
The desktop app runs locally (not in Docker) because it needs GPU and display access.
MongoDB Replica Set
Section titled “MongoDB Replica Set”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:
mongodbservice startsmongodb-initwaits for MongoDB to be readymongodb-initrunsrs.initiate()to create replica setmongodb-initexits (one-time setup)- Backend connects to replica set
Troubleshooting:
If you see “not master and slaveOk=false” errors:
# Restart MongoDB and re-initializejust downdocker volume rm flowstatecanvas_mongodb_datajust upEnvironment Variables
Section titled “Environment Variables”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.
Health Checks
Section titled “Health Checks”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: 30sCheck service health:
docker compose psOutput shows health status:
NAME STATUSbackend Up (healthy)web Up (healthy)mongodb Up (healthy)redis Up (healthy)Hot Reload
Section titled “Hot Reload”All services support hot reload for rapid development:
| Service | Hot Reload Method |
|---|---|
| Backend | tsx watch (restarts on file changes) |
| Web | Astro dev server (HMR) |
| Admin | Astro dev server (HMR) |
Changes to source files are immediately reflected in running containers without a rebuild.
Networking
Section titled “Networking”Docker Compose creates a bridge network where services communicate using service names as hostnames:
backend -> mongodb:27017backend -> redis:6379web -> backend:3000 (via SERVER_API_URL)Important: Use service names (not localhost) in container-to-container communication.
Data Persistence
Section titled “Data Persistence”Data is persisted in Docker volumes:
| Volume | Purpose |
|---|---|
mongodb_data | MongoDB database files |
redis_data | Redis persistence (AOF) |
minio_data | MinIO object storage |
Volumes survive container restarts but are deleted when running docker compose down -v.
Backup data:
# Backup MongoDBdocker compose exec mongodb mongodump --out /dumpdocker compose cp mongodb:/dump ./backup
# Backup MinIOdocker compose exec minio mc mirror /data ./backup/minioTroubleshooting
Section titled “Troubleshooting”Services won’t start
Section titled “Services won’t start”# Check logs for errorsjust logs
# Rebuild without cachejust rebuild
# Reset everythingjust downdocker volume prunejust upPort conflicts
Section titled “Port conflicts”If ports are already in use, identify the conflicting process and stop it, or update the port mapping in docker-compose.yml.
MongoDB connection errors
Section titled “MongoDB connection errors”# Check MongoDB is runningdocker compose ps mongodb
# Check replica set statusjust shell-dbrs.status()exit
# Re-initialize replica setjust downdocker volume rm flowstatecanvas_mongodb_datajust upSecrets / environment errors
Section titled “Secrets / environment errors”Verify your secrets management tooling is correctly configured. Contact your administrator if you do not have access to the development vault.
Out of disk space
Section titled “Out of disk space”# Remove unused images and volumesdocker system prune -a --volumes
# Check disk usagedocker system dfSlow performance
Section titled “Slow performance”Increase Docker Desktop resources: Docker Desktop → Settings → Resources. Recommended: 4 CPUs, 8GB RAM.
Best Practices
Section titled “Best Practices”- Always use
justcommands — Never rundocker composedirectly - Check logs first — Most issues are visible in logs
- Rebuild after dependency changes — Run
just rebuildafter updatingpackage.json - Use health checks — Wait for services to be healthy before testing
- Clean up regularly — Run
docker system pruneweekly to free disk space - Monitor resource usage — Check Docker Desktop dashboard for CPU/memory usage
- Backup data before resets —
just db-resetis destructive - Test in containers — Don’t rely on local Node.js for testing
- Keep Docker Desktop updated — Latest version has performance improvements
Production Differences
Section titled “Production Differences”Development and production Docker setups differ:
| Aspect | Development | Production |
|---|---|---|
| Images | Built locally | Pre-built on container registry |
| Secrets | Secrets management tooling | Environment variables / vault |
| Volumes | Source code mounted | No mounts (baked into image) |
| Hot reload | Enabled | Disabled |
| Ports | All exposed | Only public ports exposed |
| Networking | Bridge network | Overlay network (Swarm/K8s) |
| Logging | stdout | Centralized logging (Loki, etc.) |
| Health checks | Basic | Comprehensive with alerts |
See Production Deployment for production setup details.