version: '3.8'

services:
  web:
    build: .
    image: myapp_image
    container_name: myapp
    ports:
      - "80:80"
    volumes:
      - .:/app
      - /var/log/apache2
    environment:
      - APACHE_LOG_DIR=/var/log/apache2
    restart: always

  cloudwatch-agent:
    image: amazon/cloudwatch-agent
    container_name: cloudwatch-agent
    volumes:
      - /opt/aws/amazon-cloudwatch-agent:/opt/aws/amazon-cloudwatch-agent
      - /var/run/docker.sock:/var/run/docker.sock
      - /var/lib/docker/containers:/var/lib/docker/containers
      - /var/log/apache2:/var/log/apache2
    command: -a fetch-config -m ec2 -c file:/opt/aws/amazon-cloudwatch-agent/etc/amazon-cloudwatch-agent.json -s
    restart: always
