Overview
The Docker setup provides three services:- postgres: PostgreSQL 15 Alpine database
- api: Express backend (Node.js)
- web: Astro frontend with React islands
All services are connected via Docker’s internal network, enabling seamless communication without exposing unnecessary ports.
Prerequisites
1
Install Docker
Install Docker Desktop or Docker Engine:
- Docker Desktop (Windows/Mac/Linux)
- Docker Engine (Linux servers)
2
Install Docker Compose
Docker Compose is included in Docker Desktop. For Linux:
3
Verify Installation
Docker Compose Configuration
Thedocker-compose.yml file defines the complete stack:
docker-compose.yml
Development Deployment
Initial Setup
1
Clone Repository
2
Configure Environment Variables
Create Edit both files with your actual credentials.
.env files for both packages (see Environment Setup):3
Build and Start Containers
- Build Docker images for API and Web
- Start PostgreSQL container
- Run Prisma migrations
- Start API on port 3001
- Start Web on port 4321
Access Services
Once running, access:- Frontend: http://localhost:4321
- API: http://localhost:3001
- API Health Check: http://localhost:3001/health
- PostgreSQL:
localhost:5432(use any DB client)
Docker Commands Reference
Basic Operations
Container Management
Database Operations
Production Deployment
Docker Production Build
For production, create adocker-compose.prod.yml:
docker-compose.prod.yml
Deploy to Production
1
Set Production Environment
Create
.env.production with production credentials:2
Build Production Images
3
Start Production Stack
4
Run Migrations
Health Monitoring
Add health checks todocker-compose.prod.yml:
Alternative Deployment Options
- Vercel (Frontend)
- Railway (Backend)
- Docker + VPS
Deploy the web package to Vercel:
- Install Vercel CLI:
- Deploy from
packages/web:
- Set environment variables in Vercel dashboard:
PUBLIC_API_URLPUBLIC_GOOGLE_CLIENT_IDPUBLIC_SENTRY_DSN
PC Fix already includes
@astrojs/vercel adapter in astro.config.mjsTroubleshooting
Port already in use
Port already in use
If ports 3001, 4321, or 5432 are in use:
Container won't start
Container won't start
Check container logs:Common issues:
- Missing environment variables
- Database connection failed
- Port conflicts
Database connection refused
Database connection refused
Ensure:
- PostgreSQL container is running:
docker ps - Use host
postgresin DATABASE_URL (notlocalhost) - Wait for postgres to be ready before API starts
Changes not reflecting
Changes not reflecting
Hot reload requires volumes to be mounted correctly:
Next Steps
Database Migrations
Learn how to manage schema changes
Testing
Run tests in Docker containers
Environment Setup
Configure environment variables
Architecture
Understand the system architecture