---
version: '3'
services:
  nginx:
    image: nginx:alpine
    networks:
      - internal
      - external
    ports:
      - 3000:80
    volumes:
      - "php-storage:/var/www/html"
      - ./contrib/nginx.conf:/etc/nginx/conf.d/default.conf
    depends_on:
      - php

  php:
    build: .
    image: pixelfed
    volumes:
      - "php-storage:/var/www/html"
    networks:
      - internal
    environment:
      - DB_HOST=mysql
      - DB_DATABASE=pixelfed
      - DB_USERNAME=${DB_USERNAME:-pixelfed}
      - DB_PASSWORD=${DB_PASSWORD:-pixelfed}
      - REDIS_HOST=redis
      - APP_KEY=${APP_KEY}
    env_file:
      - ./.env

  mysql:
    image: mysql:5.7
    networks:
      - internal
    environment:
      - MYSQL_DATABASE=pixelfed
      - MYSQL_USER=${DB_USERNAME:-pixelfed}
      - MYSQL_PASSWORD=${DB_PASSWORD:-pixelfed}
      - MYSQL_RANDOM_ROOT_PASSWORD="true"
    env_file:
      - ./.env
    volumes:
      - "mysql-data:/var/lib/mysql"

  redis:
    image: redis:alpine
    volumes:
      - "redis-data:/data"
    networks:
      - internal

volumes:
  redis-data:
  mysql-data:
  php-storage:

networks:
  internal:
    internal: true
  external:
    driver: bridge
