services:
  app:
    build:
      context: ./app
      dockerfile: Dockerfile
      args:
        - PACKAGE_NAME=@wps/openapi
        - PROJECT_NAME=project-demo
    restart: always
    ports:
      - "8000:8000"
    volumes:
      - ./app/.npmrc:/usr/app/dist/.npmrc
      - ./app/.env:/usr/app/dist/.env
      - /usr/app/node_modules
    environment:
      - NODE_ENV=development
      - DB_HOST=mysql
      - DB_USER=root
      - DB_PASSWORD="U66NUBOAgLoOzugG"
      - DB_NAME=mydb
    #healthcheck:
    #  test: ["CMD-SHELL", "wget -qO- http://localhost:8000/health || exit 1"]
    #  interval: 30s
    #  timeout: 5s
    #  retries: 3
    depends_on:
      mysql:
        condition: service_healthy

  nginx:
    image: 127.0.0.1:5000/nginxinc/nginx-unprivileged:1.26-alpine
    restart: always
    ports:
      - "80:80"
    volumes:
      - ./docker/nginx/conf.d:/etc/nginx/conf.d
    healthcheck:
      test: ["CMD-SHELL", "wget -qO- http://localhost || exit 1"]
      interval: 30s
      timeout: 3s

  mysql:
    image: 127.0.0.1:5000/mysql:8.0.37
    restart: always
    ports:
      - "3306:3306"
    volumes:
      - ./docker/mysql/my.cnf:/etc/mysql/conf.d/my.cnf
      - ./docker/mysql/data:/var/lib/mysql
    environment:
      MYSQL_ROOT_PASSWORD: "U66NUBOAgLoOzugG"
      MYSQL_DATABASE: mydb
    healthcheck:
      test: ["CMD", "mysqladmin", "ping", "-h", "localhost"]
      interval: 10s
      timeout: 5s
      retries: 5
