Skip to content

Latest commit

 

History

History
157 lines (117 loc) · 2.63 KB

File metadata and controls

157 lines (117 loc) · 2.63 KB

Quick Start with Docker

Prerequisites

  • Docker and Docker Compose installed
  • .env file configured (copy from .env.example)

Starting the Application

Option 1: Start and Wait for Health Checks (Recommended)

docker-compose up --wait

This command will:

  • Build and start all services
  • Wait for MongoDB to be healthy
  • Wait for backend to be healthy and connected
  • Wait for frontend to be ready
  • Exit when all services are healthy

Option 2: Start in Detached Mode

docker-compose up -d

Then check health status:

docker-compose ps

Verifying Services

Check All Services

docker-compose ps

Expected output:

NAME                STATE               PORTS
mongo               Up (healthy)        27017/tcp
backend             Up (healthy)        5000/tcp
frontend            Up                  3000/tcp
backup              Up                  -

Check Backend Health

curl http://localhost:5000/health

Expected response:

{
  "status": "healthy",
  "timestamp": "2024-03-30T10:00:00.000Z",
  "checks": {
    "database": {
      "status": "healthy",
      "latency_ms": 5
    },
    "stellar": {
      "status": "healthy",
      "latency_ms": 150
    }
  }
}

Stopping Services

docker-compose down

To also remove volumes:

docker-compose down -v

Viewing Logs

# All services
docker-compose logs -f

# Specific service
docker-compose logs -f backend
docker-compose logs -f mongo
docker-compose logs -f frontend

Troubleshooting

Backend Won't Start

  1. Check MongoDB is healthy:

    docker-compose ps mongo
  2. View backend logs:

    docker-compose logs backend
  3. Verify environment variables in .env

MongoDB Connection Issues

  1. Check MongoDB logs:

    docker-compose logs mongo
  2. Test MongoDB connection:

    docker-compose exec mongo mongosh --eval 'db.runCommand({ ping: 1 })'

Rebuild After Changes

# Rebuild and restart
docker-compose up --build -d --wait

# Force rebuild without cache
docker-compose build --no-cache
docker-compose up -d --wait

Development Workflow

  1. Make code changes
  2. Rebuild affected service:
    docker-compose up --build backend -d
  3. Check logs:
    docker-compose logs -f backend

Health Check Details

  • MongoDB: Checks every 10s, healthy when responding to ping
  • Backend: Checks every 10s, healthy when /health returns 200
  • Startup Order: MongoDB → Backend → Frontend

See docs/docker-health-checks.md for detailed information.