version: '3.7'

services:
  nginx-memo:
    build: dockerfile_nginx
    image: itsjanis/nginx-memo:latest
    container_name: nginx-memo
    volumes:
    - "./www:/usr/share/nginx/html:ro"
    - "./log:/var/log/nginx"
    - "./nginx.conf:/etc/nginx/nginx.conf:ro"
    ports:
    - published: 85
      target: 80
    networks:
      - databases

  php:
    build: dockerfile_php
    image: itsjanis/php-memo:latest
    depends_on:
      - redis-memo
      - postgresql-memo
      - nginx-memo
    container_name: php-memo
    volumes:
    - "./www:/script"
    networks:
      - databases

  postgresql-memo:
    build: dockerfile_postgres
    image: itsjanis/postgresql-memo:latest
    restart: unless-stopped
    container_name: postgresql-memo
    environment:
      POSTGRES_USER: admin
      POSTGRES_PASSWORD: password
      POSTGRES_DB: memo
    ports:
    - published: 5432
      target: 5432
    volumes:
      - "./pgsql-scripts:/docker-entrypoint-initdb.d"
      - "postgres_data:/var/lib/postgresql/data"
    networks:
      - databases

  redis-memo:
    build: dockerfile_redis    
    image: itsjanis/redis-memo:latest  
    restart: unless-stopped
    container_name: redis-memo
    ports:
    - published: 6380
      target: 6379
    volumes:
    - ./www/data/redis_data/taches.redis:/redisdata/data/taches.redis
    - ./redis_rdb:/redisdata/rdb
    - redis_data:/data
    networks:
      - databases
    # command: redis-server --dbfilename dump.rdb --dir /data


  adminer-memo:
    build: dockerfile_adminer
    image: itsjanis/adminer-memo:latest
    restart: unless-stopped
    container_name: adminer-memo
    ports:
    - published: 8080
      target: 8080
    networks:
      - databases

  # composer-memo:
  #   image: composer:1.9.3
  #   environment:
  #     - COMPOSER_CACHE_DIR=/app/var/cache/composer
  #   volumes:
  #     - ./composer:/app
  #   # restart: never
  
volumes:
  postgres_data:
  redis_data:

networks:
  databases:
    driver: bridge