services:
  php:
    image: php:7.4-fpm-alpine
    volumes:
      - ./www:/usr/share/nginx/html
      - ./www/php-fpm/www.conf:/usr/local/etc/php-fpm.d/www.conf
    command: >
      sh -c "apk add --no-cache $PHPIZE_DEPS && docker-php-ext-install mysqli pdo_mysql && apk del $PHPIZE_DEPS && php-fpm"

  nginx:
    image: nginx:stable-alpine
    ports:
      - "8080:80"
    volumes:
      - ./nginx/default.conf:/etc/nginx/conf.d/default.conf:ro
      - ./www:/usr/share/nginx/html
    depends_on:
      - php
    # 使用nc探测tcp端口，不再用wget（wget不兼容fastcgi）
    command: ["/bin/sh", "-c", "until nc -z php 9000; do echo '等待php-fpm端口就绪...'; sleep 1; done; nginx -g 'daemon off;'"]
