version: "3.7"
services:
  php:
    # image: registry.gitlab.com/skvad-dev/php7.3-nodejs:latest
    image: registry.gitlab.com/skvad-dev/php:8.0
    ports:
      - 32774:80
    restart: unless-stopped
    depends_on:
      - db
    volumes:
      - .:/var/www/
    environment:
      - DB_PORT=${DB_PORT}
      - DB_HOST=${DB_HOST}
    container_name: skvadmin-web
    security_opt:
      - no-new-privileges:true
    labels:
      # Enable this container to be mapped by traefik
      # For more information, see: https://docs.traefik.io/providers/docker/#exposedbydefault
      - "traefik.enable=true"
      # URL to reach this container
      - "traefik.http.routers.skvadmin.rule=Host(`skvadmin.local.test`)"
      # Activation of TLS
      - "traefik.http.routers.skvadmin.tls=true"
      # If port is different than 80, use the following service:
      # - "traefik.http.services.<service_name>.loadbalancer.server.port=<port>"
    networks:
      - proxy

  db:
    image: mysql:8
    environment:
      - MYSQL_ROOT_PASSWORD=${ROOT_PASSWORD}
      - MYSQL_DATABASE=${DB_DATABASE}
      - MYSQL_USER=${DB_USERNAME}
      - MYSQL_PASSWORD=${DB_PASSWORD}
    ports:
      - 32775:3306
    restart: unless-stopped
    volumes:
      # - ./db/dump.sql:/docker-entrypoint-initdb.d/dump.sql
      - db-volume:/var/lib/mysql
    command:
      [
        "mysqld",
        "--character-set-server=utf8mb4",
        "--collation-server=utf8mb4_unicode_ci",
      ]
    container_name: skvadmin-db
    networks:
      - proxy

  smtp:
    image: mailhog/mailhog:latest
    restart: unless-stopped
    ports:
      - 1025:1025
      - 8025:8025
    networks:
      - proxy

  adminer:
    image: adminer:standalone
    ports:
      - 32776:8080
    restart: unless-stopped
    depends_on:
      - db
    environment:
      ADMINER_DESIGN: nette
      ADMINER_PLUGINS: dump-date edit-calendar enum-option enum-types sql-log struct-comments tables-filter
    container_name: skvadmin-adminer
    security_opt:
      - no-new-privileges:true
    labels:
      # Enable this container to be mapped by traefik
      # For more information, see: https://docs.traefik.io/providers/docker/#exposedbydefault
      - "traefik.enable=true"
      # URL to reach this container
      - "traefik.http.routers.skvadmin-adminer.rule=Host(`db-skvadmin.local.test`)"
      # Activation of TLS
      - "traefik.http.routers.skvadmin-adminer.tls=true"
      # If port is different than 80, use the following service:
      # - "traefik.http.services.<service_name>.loadbalancer.server.port=<port>"
    networks:
      - proxy

networks:
  proxy:
    external: true

volumes:
  db-volume:
