version: "3.8"

networks:
  castopod:
    ipam:
      config:
        - subnet: 172.31.0.0/24

services:
  app:
    build:
      context: .
      dockerfile: docker/development/Dockerfile
    container_name: app
    command: /bin/sh -c "crontab ./crontab && cron && service cron reload && php spark serve --host 0.0.0.0"
    ports:
      - 8080:8080
    volumes:
      - .:/castopod
    depends_on:
      - redis
      - mariadb
    networks:
      castopod:
        ipv4_address: 172.31.0.2

  redis:
    image: redis:alpine
    container_name: castopod_redis
    ports:
      - 6379:6379
    volumes:
      - redis:/data
    networks:
      castopod:
        ipv4_address: 172.31.0.3

  mariadb:
    image: mariadb:10.2
    container_name: castopod_mariadb
    ports:
      - 3306:3306
    volumes:
      - ./initdb:/docker-entrypoint-initdb.d
      - mariadb:/var/lib/mysql
    environment:
      MYSQL_ROOT_PASSWORD: root
      MYSQL_DATABASE: castopod
      MYSQL_USER: castopod
      MYSQL_PASSWORD: castopod
    networks:
      castopod:
        ipv4_address: 172.31.0.4

  phpmyadmin:
    image: phpmyadmin/phpmyadmin:latest
    container_name: castopod_phpmyadmin
    environment:
      PMA_HOST: mariadb
      PMA_PORT: 3306
      UPLOAD_LIMIT: 300M
    ports:
      - 8888:80
    volumes:
      - phpmyadmin:/sessions
    depends_on:
      - mariadb
    networks:
      castopod:
        ipv4_address: 172.31.0.5

  s3:
    image: adobe/s3mock:latest
    container_name: castopod_s3
    environment:
      - initialBuckets=castopod
      - debug=true
      - root=/data
    ports:
      - 9090:9090
    volumes:
      - ./data/s3:/data:cached
    networks:
      castopod:
        ipv4_address: 172.31.0.6

volumes:
  redis:
  mariadb:
  phpmyadmin:
