Docker Compose For PHP Development

[1] Prep docker-compose.yml

version: '3.7'

services:
  web:
    build:
      context: .
      dockerfile: Dockerfile
    ports:
      - "8080:80"  # Expose port 80 inside the container to port 8080 on the host machine
    volumes:
      - ./src:/var/www/html  # Mount the src directory to the web server's document root
    networks:
      - app_network

  db:
    image: mysql:5.7
    environment:
      MYSQL_ROOT_PASSWORD: rootpassword
      MYSQL_DATABASE: mydatabase
      MYSQL_USER: user
      MYSQL_PASSWORD: password
    volumes:
      - db_data:/var/lib/mysql  # Persist database data between container restarts
    networks:
      - app_network

  phpmyadmin:
    image: phpmyadmin/phpmyadmin
    environment:
      PMA_HOST: db
      MYSQL_ROOT_PASSWORD: rootpassword
    ports:
      - "8081:80"  # Expose phpMyAdmin on port 8081
    networks:
      - app_network

networks:
  app_network:
    driver: bridge

volumes:
  db_data:

[2] Start container

docker-compose up --build