version: "3.8"

services:
  imprimelibros-db:
    image: mysql:8.0
    container_name: imprimelibros-db
    environment:
      MYSQL_ROOT_PASSWORD: NrXz6DK6UoN
      MYSQL_DATABASE: imprimelibros
      MYSQL_USER: imprimelibros_user
      MYSQL_PASSWORD: om91irrDctd
    volumes:
      - db_data:/var/lib/mysql
    networks:
      - imprimelibros-network
    restart: always
    ports:
      - "3309:3306"   # host:container

  imprimelibros-app:
    build:
      context: .
      dockerfile: Dockerfile
    image: imprimelibros-app:latest
    container_name: imprimelibros-app
    depends_on:
      - imprimelibros-db
    environment:
      SPRING_DATASOURCE_URL: jdbc:mysql://imprimelibros-db:3306/imprimelibros?useSSL=false&allowPublicKeyRetrieval=true&serverTimezone=Europe/Madrid
      SPRING_DATASOURCE_USERNAME: imprimelibros_user
      SPRING_DATASOURCE_PASSWORD: om91irrDctd
    ports:
      - "8080:8080"
    restart: always
    networks:
      - imprimelibros-network

volumes:
  db_data:

networks:
  imprimelibros-network:
    driver: bridge
