version: '3.9'

services:
  nginx:
    image: nginx:stable-alpine
    container_name: nginx-memo
    volumes:
    - "./www:/usr/share/nginx/html:ro"
    - "./log:/var/log/nginx"
    - "./nginx.conf:/etc/nginx/nginx.conf:ro"
    ports:
    - published: 80
      target: 80
    networks:
      - databases

  php:
    build:
      dockerfile: dockerfile_php
    container_name: php-memo
    volumes:
    - "./www:/script"
    networks:
      - databases

  postgresql-memo:
    build:
      dockerfile: dockerfile_postgres
    restart: unless-stopped
    container_name: postgresql-memo
    environment:
      POSTGRES_USER: admin
      POSTGRES_PASSWORD: password
    ports:
    - published: 5432
      target: 5432
    volumes:
      - "./pgsql-scripts:/docker-entrypoint-initdb.d"
      - "postgres_data:/var/lib/postgresql/data"
    networks:
      - databases
    # command: echo "fuck" &
    # command: psql -U user -d postgres -f postgresqldata/data/datapostgres.sql

  redis-memo:
    image: redis:latest
    restart: unless-stopped
    container_name: redis-memo
    ports:
    - published: 6379
      target: 6379
    volumes:
    - ./www/data/redis_data:/redisdata/data:rw
    networks:
      - databases

  adminer:
    image: adminer
    restart: unless-stopped
    container_name: adminer-memo
    ports:
    - published: 8080
      target: 8080
    networks:
      - databases
  
volumes:
  postgres_data:
  redis_data:

networks:
  databases:
    driver: bridge