version: '3.3'

services:
  mysqlcontainer:
    image: mysql
    container_name: mysqlcontainer
    environment:
      MYSQL_ROOT_PASSWORD: 6EAtGAAFXXCcu
      MYSQL_DATABASE: slcmpnew
      MYSQL_USER: slc
      MYSQL_PASSWORD: 6EAtGXCcu
    ports:
      - 3307:3307
    networks:
      - networkparcours
    volumes:
      - parcoursdatabase:/var/lib/mysql
      
  springcontainer:
    build:
      context: .
      dockerfile: Dockerfile
    container_name: springcontainer
    ports:
      - 8085:8085
    networks:
      - networkparcours
    environment:
      MYSQL_HOST: mysqlcontainer
      MYSQL_PORT: 3307
      MYSQL_DB_NAME: slcmpnew
      MYSQL_USER: slcmpnew
      MYSQL_PASSWORD: Q804cFrW2Eex
      SPRING_DATASOURCE_URL: jdbc:mysql://mysqlcontainer:3307/slcmpnew?createDatabaseIfNotExists=true&autoReconnect=true&allowPublicKeyRetrieval=true&useSSL=false&sessionVariables=sql_mode='NO_ENGINE_SUBSTITUTION'&jdbcCompliantTruncation=false
      SPRING_DATASOURCE_USERNAME: slc
      SPRING_DATASOURCE_PASSWORD: 6EAtGXCcu
      SPRING_DATASOURCE_INITIALIZATION_MODE: always
      SPRING_DATASOURCE_DRIVER_CLASS_NAME: com.mysql.jdbc.Driver
      SPRING_JPA_DATABASE_PLATFORM: org.hibernate.dialect.MySQL8Dialect
      SPRING_JPA_SHOW_SQL: "true"
      SPRING_JPA_HIBERNATE_DDL_AUTO: update
  frontcontainer:
    build:
      context: ../Front-Parcours
      dockerfile: Dockerfile
    container_name: frontcontainer
    ports:
      - 80:80
    networks:
      - networkparcours
    depends_on:
      - springcontainer 
    command: sh -c "sleep 10 && nginx -g 'daemon off;'"
networks:
  networkparcours:  
    external: true
volumes:
  parcoursdatabase: