services:
  ant-project:
    build:
      context: .
      dockerfile: Dockerfile
    ports:
      - '3000:3000'
    environment:
      NODE_ENV: production
    depends_on:
      - ghost-cms

  ghost-cms:
    image: ghost:5-alpine
    ports:
      - '2368:2368'
    environment:
      url: http://localhost:2368
      database__client: mysql
      database__connection__host: mysql
      database__connection__user: root
      database__connection__password: rootpassword
      database__connection__database: ghostdb
    volumes:
      - ./ghost-data:/var/lib/ghost/content
    depends_on:
      mysql:
        condition: service_healthy

  mysql:
    image: mysql:8
    ports:
      - '3306:3306'
    environment:
      MYSQL_ROOT_PASSWORD: rootpassword
      MYSQL_DATABASE: ghostdb
    volumes:
      - mysql-data:/var/lib/mysql
    healthcheck:
      test: ["CMD", "mysqladmin", "ping", "-h", "localhost"]
      interval: 10s
      timeout: 5s
      retries: 3

  nginx:  
    image: nginx:alpine
    ports:
      - '80:80'
    volumes:
      - ./nginx.conf:/etc/nginx/nginx.conf
    depends_on:
      - ant-project
      - ghost-cms


volumes:
  ghost-data:
  mysql-data:
  ant-project:

