version: '3.8'
version: '3.8'

services:
  php:
    build:
      context: ./docker/php
      dockerfile: Dockerfile-simple
    volumes:
      - ./src:/var/www/html/src:rw
      - ./public:/var/www/html/public:rw
    networks:
      - backend

  nginx:
    image: nginx:alpine
    ports:
      - "80:80"
      - "443:443"
    volumes:
      - ./public:/var/www/html/public:ro
      - ./docker/nginx/nginx.conf:/etc/nginx/nginx.conf:ro
      - ./docker/nginx/default.conf:/etc/nginx/conf.d/default.conf:ro
    depends_on:
      - php
    networks:
      - frontend
      - backend

  redis:
    image: redis:alpine
    networks:
      - cache

networks:
  frontend:
  backend:
  cache:
services:
  php:
    build:
      context: ./docker/php
      dockerfile: Dockerfile
    volumes:
      - ${DEPLOY_ROOT:-/var/www/michaelschiemer}/src:/var/www/html/src:rw
      - ${DEPLOY_ROOT:-/var/www/michaelschiemer}/public:/var/www/html/public:rw
    networks:
      - backend

  nginx:
    build:
      context: ./docker/nginx
      dockerfile: Dockerfile
    ports:
      - "80:80"
      - "443:443"
    volumes:
      - ${DEPLOY_ROOT:-/var/www/michaelschiemer}/public:/var/www/html/public:ro
      - ${DEPLOY_ROOT:-/var/www/michaelschiemer}/ssl:/etc/nginx/ssl:ro
    depends_on:
      - php
    networks:
      - frontend
      - backend

  redis:
    image: redis:alpine
    networks:
      - cache

networks:
  frontend:
  backend:
  cache:
