# docker-compose.yaml
# https://www.devpowerup.com/php-docker
version: '3'

services:
  app:
    build:
      context: .
      dockerfile: docker/Dockerfile
    container_name: app
    tty: true
    depends_on:
      - db
    environment:
      DATABASE_URL: postgresql://dbuser:bigsecret@127.0.0.1:5432/devdb
    working_dir: /var/www
    volumes:
      - ./:/var/www

  webserver:
    image: nginx:stable
    container_name: webserver
    restart: always
    ports:
      - "8080:80"
    depends_on:
      - app
    volumes:
      - ./:/var/www
      - ./docker/app.conf:/etc/nginx/conf.d/default.conf
    links:
      - app

  db:
    image: postgres:14
    container_name: db
    restart: always
    volumes:
      - db_data:/var/lib/postgresql/data
    environment:
      POSTGRES_PASSWORD: devsecret
      POSTGRES_USER: devuser
      POSTGRES_DB: devdb
    ports:
      - "5432:5432"

volumes:
  db_data: