version: '2'
services:
  mysql:
    image: mysql
    volumes:
      - ./.data:/var/lib/mysql
    environment:
      MYSQL_ROOT_PASSWORD: password
  api:
    build: ./php
    volumes:
      - ./php:/var/www:ro
  react:
    build: ./react
    volumes:
      - ./react/build:/app:ro
    environment:
      API: http://api
    links:
      - api
      - mysql
  nginx:
    image: nginx:alpine
    ports:
      - "80:80"
    volumes:
      - ./nginx/nginx.conf:/etc/nginx/nginx.conf
    command: "nginx"
    links:
      - api
      - react

version: '2'
services:
  mysql:
    image: mysql
    volumes:
      - ./.data:/var/lib/mysql
    environment:
      MYSQL_ROOT_PASSWORD: password
  api:
    build: ./php
    volumes:
      - ./php:/var/www:ro
  react:
    build: ./react
    volumes:
      - ./react/build:/app:ro
    environment:
      API: http://api
    links:
      - api
      - mysql
    environment:
      API: http://api:80
  nginx:
    image: nginx:alpine
    ports:
      - "80:80"
    volumes:
      - ./nginx/nginx.conf:/etc/nginx/nginx.conf
    command: "nginx"
    links:
      - api
      - react

Set API environment variable in docker-compose.yml
Set API environment variable in docker-compose.yml
