version: "3.7"
services:
  backend:
    build:
      args:
      - NODE_ENV=development
      context: backend
    command: ../node_modules/.bin/nodemon --inspect=0.0.0.0:9229
    environment:
    - NODE_ENV=development
    ports:
    - 8080:80
    - 9229:9229
    - 9230:9230
    volumes:
    - ./backend:/opt/app:delegated
    - ./backend/package.json:/opt/package.json
    - ./backend/package-lock.json:/opt/package-lock.json
    - back-notused:/opt/app/node_modules
    depends_on: 
      - db
  db:
    environment:
      MYSQL_DATABASE: example
      MYSQL_ROOT_PASSWORD_FILE: /run/secrets/db-password
    image: mysql:5.7
    restart: always
    secrets:
    - db-password
    volumes:
    - db-data:/var/lib/mysql
  frontend:
    build: frontend
    ports:
    - 80:9000
    volumes:
    - ./frontend:/project
    - /project/node_modules
    depends_on: 
    - backend
volumes:
  back-notused: {}
  db-data: {}
secrets:
  db-password:
    file: db/password.txt
