version: '3'

services:

  myreverse:
    image: bunkerity/bunkerized-nginx
    restart: always
    depends_on:
      - app1
      - app2
    ports:
      - 80:8080
      - 443:8443
    # bunkerized-nginx runs as an unprivileged user with UID/GID 101
    # don't forget to edit the permissions of the files and folders accordingly
    volumes:
      - ./letsencrypt:/etc/letsencrypt
      - ./server-confs:/server-confs:ro                      # redirect /app1 and /app2 to /app1/ and /app2/
    environment:
      - SERVER_NAME=www.website.com                          # replace with your domain
      - SERVE_FILES=no
      - DISABLE_DEFAULT_SERVER=yes
      - REDIRECT_HTTP_TO_HTTPS=yes
      - AUTO_LETS_ENCRYPT=yes
      - USE_PROXY_CACHE=yes
      - USE_CLIENT_CACHE=yes
      - USE_GZIP=yes
      - USE_REVERSE_PROXY=yes
      - REVERSE_PROXY_URL_1=/app1/
      - REVERSE_PROXY_HOST_1=http://app1:3000/
      - REVERSE_PROXY_URL_2=/app2/
      - REVERSE_PROXY_HOST_2=http://app2/

  app1:
    image: node
    restart: always
    working_dir: /home/node/app
    volumes:
      - ./js-app:/home/node/app
    environment:
      - NODE_ENV=production
    command: bash -c "npm install express && node index.js"

  app2:
    image: phpmyadmin:apache
    restart: always
    environment:
      - PMA_ARBITRARY=1
      - PMA_ABSOLUTE_URI=https://www.website.com/app2/      # replace with your absolute URI
