
version: '2.0'

services:
  mysqlcontainer:
    image: mysql:5.7
    container_name: mysqlcontainer
    environment:
      MYSQL_ROOT_PASSWORD: 6EAtGAAFXXCcu
      MYSQL_DATABASE: slcmpnew
      MYSQL_USER: slc
      MYSQL_PASSWORD: 6EAtGXCcu
    ports:
      - 3307:3306
    networks:
      - networkparcours
    volumes:
      - /home/docker/mysql_data:/var/lib/mysql
    #command: --skip-networking=false --sql-mode=""
  springcontainer:
    build:
      context: .
      dockerfile: Dockerfile
    container_name: springcontainer
    ports:
      - 8085:8085
    networks:
      - networkparcours
    environment:
      MYSQL_HOST: mysqlcontainer
      MYSQL_PORT: 3306
      MYSQL_DB_NAME: slcmpnew
      MYSQL_USER: slc
      MYSQL_PASSWORD: Q804cFrW2Eex
      SPRING_DATASOURCE_URL: jdbc:mysql://mysqlcontainer:3306/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
    depends_on:
       - mysqlcontainer
  frontcontainer:
    build:
      context: ../Front-Parcours
      dockerfile: Dockerfile
    container_name: frontcontainer
    ports:
      - 80:80
      - 443:443
    restart: always
    volumes:
      - $PWD/certbot/conf:/etc/nginx/ssl
      - $PWD/certbot/data:/usr/share/nginx/html/letsencrypt
    networks:
      - networkparcours
  certbot:
    image: certbot/certbot:latest
    #command: sh -c "trap 'exit 0' TERM && while :; do certbot renew; sleep 12h & wait $${!}; done;"
    command: certonly --webroot --webroot-path=/usr/share/nginx/html/letsencrypt --email najia@slc-assurances.fr --agree-tos --no-eff-email --staging -d comparateur.slc-assurances.fr
    #command: certonly --webroot --webroot-path=/usr/share/nginx/html/letsencrypt --email najia@slc-assurances.fr --agree-tos --no-eff-email --staging -d comparateur.slc-assurances.fr -d scraping.slassurances.fr
    volumes:
      - $PWD/certbot/conf:/etc/letsencrypt
      - $PWD/certbot/logs:/var/log/letsencrypt
      - $PWD/certbot/data:/usr/share/nginx/html/letsencrypt
    
networks:
  networkparcours:  
    external: true
volumes:
  parcoursdatabase:
