version: "3.4"
services:
  database:
    image: "mysql:5.7"
    command: mysqld --character-set-server=utf8 --collation-server=utf8_unicode_ci
    environment:
      MYSQL_DATABASE: peeringdb
      MYSQL_USER: peeringdb
      MYSQL_PASSWORD: devPASSWORD
      MYSQL_ALLOW_EMPTY_PASSWORD: 1
      #MYSQL_ROOT_PASSWORD: devPASSWORD
#    # set logging options to output in json
#    logging:
#      driver: json-file
#      options:
#        max-size: 100m
#        max-file: "3"
    restart: always
    ports:
     - "13306:3306"
    volumes:
      - ./peeringdb_database:/var/lib/mysql:Z

  peeringdb:
    user: "0:0"
    build:
      context: ../..
      dockerfile: Dockerfile
      target: tester
    command: runserver 0.0.0.0:8000
    env_file: .env
    environment:
      DATABASE_USER: peeringdb
      DATABASE_PASSWORD: devPASSWORD
      DATABASE_HOST: database
#    # set logging options to output in json
#    logging:
#      driver: json-file
#      options:
#        max-size: 100m
#        max-file: "3"
    ports:
      # this needs to be set in the shell, compose env vars aren't read yet
      - "${DJANGO_PORT:-8000}:8000"
    volumes:
      - ../../peeringdb_server:/srv/www.peeringdb.com/peeringdb_server:Z
      - ../../mainsite:/srv/www.peeringdb.com/mainsite:Z
      - ../../tests:/srv/www.peeringdb.com/tests:Z
      - ../../docs:/srv/www.peeringdb.com/docs:Z

      # uncomment if you want indexed search data to be persistent
      # - ../../search-data:/srv/www.peeringdb.com/search-data

      # uncomment if you want api cache files to be persistent
      # - ../../api-cache:/srv/www.peeringdb.com/api-cache

      # uncomment if you want localization to be available for development
      #
      # expects a https://github.com/peeringdb/translations source checkout in the parent
      # directory
      # - ../../../translations/locale:/srv/www.peeringdb.com/locale:Z

      # uncomment if you want a django-peeringdb source checkout
      # to be available for development
      #
      # expects a https://github.com/peeringdb/django-peeringdb source checkout in the parent
      # directory
      # - ../../../django-peeringdb/src/django_peeringdb:/srv/www.peeringdb.com/venv/lib/python3.9/site-packages/django_peeringdb:Z


volumes:
  peeringdb_database:
