#####
# Docker compose YAML file
#
# For documentation see: https://docs.docker.com/compose/yml/
#####
version: '3'
volumes:
  data:

services:
  nginx-proxy:
    image: jwilder/nginx-proxy
    container_name: nginx-proxy
    ports:
      - "7070:80"
    restart: always
    volumes:
      - /var/run/docker.sock:/tmp/docker.sock:ro
      - /srv/docker/nginx/my_proxy.conf:/etc/nginx/conf.d/my_proxy.conf:ro

  whoami:
    image: jwilder/whoami
    container_name: whoami
    environment:
      - VIRTUAL_HOST=whoami.local

  db:
    build:
      context: dockerbuild/mongo/
      dockerfile: Dockerfile
    container_name: accounting-mongodb
    ports:
      - "27018:27017"
    volumes:
      - /srv/docker/accountingdb:/data/db
    env_file:
      - ./dockerbuild/config.env
    networks:
      - default
    restart: always

  tomcat:
    image: tomcat:8.5
    container_name: toposoft-tomcat
    volumes:
      - data:/usr/local/tomcat/webapps
      - data:/root/.m2
      - data:/files
    env_file:
      - ./dockerbuild/config.env
    links:
      - db:mongodb
    environment:
      - VIRTUAL_HOST=accounting.toposoft.lv
    restart: always
    networks:
      - default

  web:
    build: .
    container_name: accounting-web
    env_file:
      - ./dockerbuild/config.env
    links:
      - db:mongodb
      - tomcat:tomcat
    volumes:
      - data:/usr/local/tomcat/webapps
      - data:/root/.m2
      - data:/files
    networks:
      - default

  data:
    image: busybox
    volumes:
      - data:/usr/local/tomcat/webapps
      - data:/root/.m2
      - /srv/docker/files:/files:rw

  builder:
    build:
      context: dockerbuild/builder/
      dockerfile: Dockerfile
    container_name: toposoft-dev-package
    links:
      - db:mongodb
    env_file:
      - ./dockerbuild/config.env
    volumes:
      - data:/usr/local/tomcat/webapps
      - data:/root/.m2
      - data:/files
      - data:/usr/local/src/src
      - ./target:/usr/local/src/target
      - /tmp/m2:/root/.m2
    networks:
      - default
    working_dir: /usr/local/src
    command: deploy.sh

