version: '3.4'

services:
  php:
    image: quay.io/sylius/php:latest
    depends_on:
      - mysql
    environment:
      - APP_ENV=prod
      - APP_DEBUG=0
      - APP_SECRET=EDITME
      - DATABASE_URL=mysql://root@127.0.0.1/sylius_%kernel.environment%
      - MAILER_URL=smtp://localhost
      - PHP_DATE_TIMEZONE=${PHP_DATE_TIMEZONE:-UTC}
    volumes:
      # use a bind-mounted host directory, as we want to keep the sessions
      - ./var/sessions:/srv/sylius/var/sessions:rw
      # use a bind-mounted host directory, as we want to keep the media
      - ./public/media:/srv/sylius/public/media:rw

  mysql:
    # in production, we may want to use a managed database service
    image: percona:5.7
    environment:
      - MYSQL_ROOT_PASSWORD=${MYSQL_ROOT_PASSWORD:?MYSQL_ROOT_PASSWORD is not set or empty}
      - MYSQL_DATABASE=sylius_prod
      - MYSQL_USER=sylius
      - MYSQL_PASSWORD=${MYSQL_PASSWORD:?MYSQL_PASSWORD is not set or empty}
    volumes:
      # use a bind-mounted host directory, because we never want to lose our data!
      - ./docker/mysql/data:/var/lib/mysql:rw,delegated

  nginx:
    # in production, we may want to use a static website hosting service
    image: quay.io/sylius/nginx:latest
    depends_on:
      - php
    volumes:
      # use a bind-mounted host directory, as we want to keep the media
      - ./public/media:/srv/sylius/public/media:ro
    ports:
      - "80:80"
