version: '3'

services:

  mywww:
    image: bunkerity/bunkerized-nginx
    restart: always
    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
      - autoconf:/etc/nginx
    environment:
      - SERVER_NAME=                                              # must be left blank if you don't want to setup "static" conf
      - MULTISITE=yes
      - AUTO_LETS_ENCRYPT=yes
      - REDIRECT_HTTP_TO_HTTPS=yes
      - DISABLE_DEFAULT_SERVER=yes
      - USE_CLIENT_CACHE=yes
      - USE_PROXY_CACHE=yes
      - USE_GZIP=yes
      - USE_REVERSE_PROXY=yes
    labels:
      - "bunkerized-nginx.AUTOCONF"

  myautoconf:
    image: bunkerity/bunkerized-nginx-autoconf
    restart: always
    volumes:
      - /var/run/docker.sock:/var/run/docker.sock:ro
      - autoconf:/etc/nginx
    depends_on:
      - mywww
      - myapp1
      - myapp2
      - myapp3

  myapp1:
    build: js-app
    restart: always
    environment:
      - NODE_ENV=production
    labels:
      - "bunkerized-nginx.SERVER_NAME=app1.website.com"            # replace with your domain
      - "bunkerized-nginx.REVERSE_PROXY_URL=/"
      - "bunkerized-nginx.REVERSE_PROXY_HOST=http://myapp1:3000"

  myapp2:
    build: js-app
    restart: always
    environment:
      - NODE_ENV=production
    labels:
      - "bunkerized-nginx.SERVER_NAME=app2.website.com"            # replace with your domain
      - "bunkerized-nginx.REVERSE_PROXY_URL=/"
      - "bunkerized-nginx.REVERSE_PROXY_HOST=http://myapp2:3000"

  myapp3:
    build: js-app
    restart: always
    environment:
      - NODE_ENV=production
    labels:
      - "bunkerized-nginx.SERVER_NAME=app3.website.com"            # replace with your domain
      - "bunkerized-nginx.REVERSE_PROXY_URL=/"
      - "bunkerized-nginx.REVERSE_PROXY_HOST=http://myapp3:3000"

volumes:
  autoconf:
