version: "3"
services:
  nginx:
    restart: unless-stopped
    depends_on:
      - fpm
    build:
      dockerfile: ./build/nginx/Dockerfile
      target: ${ENVIRONMENT}
      args:
        USER: ${USER_ID}
        GROUP: ${GROUP_ID}
        FPMHOST: ${FPMHOST}
    image: ${IMAGE_NAME}/nginx:${IMAGE_TAG}
    ports:
      - 8080:80
    working_dir: /html
  #    volumes:
  #      - ./app:/html
  fpm:
    restart: unless-stopped
    build:
      dockerfile: ./build/fpm/Dockerfile
      target: ${ENVIRONMENT}
      args:
        USER: ${USER_ID}
        GROUP: ${GROUP_ID}
    image: ${IMAGE_NAME}/fpm:${IMAGE_TAG}
    volumes:
      #      - ./app:/html
      - vendor:/html/vendor
      - bootstrap-cache:/html/bootstrap/cache
  assets:
    restart: unless-stopped
    image: ${IMAGE_NAME}/node:${NODE_TAG}
    build:
      dockerfile: ./build/node/Dockerfile
      args:
        USER: ${USER_ID}
        GROUP: ${GROUP_ID}
    volumes:
      - ./app:/app
      - npm-cache:/home/mgmaps/.npm
  composer:
    restart: on-failure
    build:
      dockerfile: ./build/fpm/Dockerfile
      target: composer
      args:
        USER: ${USER_ID}
        GROUP: ${GROUP_ID}
        COMPOSER_VERSION: ${COMPOSER_VERSION}
    image: ${IMAGE_NAME}/composer:${COMPOSER_VERSION}
    volumes:
      - ./app:/html
      - composer-cache:/mgmaps/.composer
      - vendor:/html/vendor
      - bootstrap-cache:/html/bootstrap/cache
volumes:
  composer-cache: {}
  npm-cache: {}
  vendor: {}
  bootstrap-cache: {}
