version: '3.6'

services:

  db:
    image: fresh/db
    hostname: db.HOSTNAMEREPLACE
    container_name: db.HOSTNAMEREPLACE
    volumes:
      - ./artifacts/db/data:/var/lib/1c/pgdata
      - ./mnt:/mnt
      - ../images/site/create_db.psql:/create_db_site.psql
      - ../images/forum/create_db.psql:/create_db_forum.psql
      - ../images/db/wait_postgres.sh:/wait_postgres.sh
  
  nginx:
    image: nginx:stable-alpine
    hostname: nginx.HOSTNAMEREPLACE
    container_name: nginx.HOSTNAMEREPLACE
    networks: 
      default:
        aliases:
          - HOSTNAMEREPLACE
    environment:
      - SITE_HOST=site.HOSTNAMEREPLACE
      - BACKEND_HOST=web.HOSTNAMEREPLACE
      - GATE_HOST=gate.HOSTNAMEREPLACE
      - HOSTNAME=HOSTNAMEREPLACE
    ports:
      - 80:80
      - 443:443
    volumes:
      - ./artifacts/nginx/conf/1c_app.conf:/etc/nginx/1c_app.conf
      - ./artifacts/nginx/conf/1c_common.conf:/etc/nginx/1c_common.conf
      - ./artifacts/nginx/conf/1c_error.conf:/etc/nginx/1c_error.conf
      - ./artifacts/nginx/conf/1c_error_openid.conf:/etc/nginx/1c_error_openid.conf
      - ./artifacts/nginx/conf/1c_error_site.conf:/etc/nginx/1c_error_site.conf
      - ./artifacts/nginx/conf/1c_keepalive.conf:/etc/nginx/1c_keepalive.conf
      - ./artifacts/nginx/conf/1c_upstream.conf:/etc/nginx/1c_upstream.conf
      - ./artifacts/nginx/conf/nginx.conf:/etc/nginx/nginx.conf
      - ./artifacts/nginx/conf/conf.d/local-ssl.conf:/etc/nginx/conf.d/local-ssl.conf
      - ./artifacts/nginx/conf/conf.d/local.conf://etc/nginx/conf.d/local.conf
      - ./artifacts/nginx/log:/var/log/nginx
      - ./mnt:/mnt
      - ../certs/fullchain.pem:/etc/pki-custom/fullchain.crt
      - ../certs/privkey.pem:/etc/pki-custom/privkey.key
      - ../images/site/distr/site/media:/var/www/content/media/
    depends_on:
      - site
      - forum

  srv:
    image: fresh/core
    hostname: srv.HOSTNAMEREPLACE
    container_name: srv.HOSTNAMEREPLACE
    command: srv+cli
    volumes:
      - ./artifacts/srv/data:/var/lib/1c/data
      - ./artifacts/srv/log:/var/log/1c
      - ./mnt:/mnt
      - /tmp/.aksusb:/tmp/.aksusb
      - ../licenses_1c:/var/1C/licenses
      - ../conf/core:/opt/1C/v8.3/x86_64/conf
      
    ports:
      - 1540-1541:1540-1541
      - 1538:1538
      - 1550:1550
      - 1560-1591:1560-1591
      - 5900:5900
    depends_on:
      - db

  ras:
    image: fresh/core
    hostname: ras.HOSTNAMEREPLACE
    container_name: ras.HOSTNAMEREPLACE
    command: /opt/1C/v8.3/x86_64/ras cluster --port=1545 srv:1540
    volumes:
      - ./artifacts/ras/log:/var/log/1c
      - ./mnt:/mnt
      - ../images/core/conf/logcfg.xml:/opt/1C/v8.3/x86_64/conf/logcfg.xml
    ports:
      - 1545:1545
      
  web:
    image: fresh/core
    hostname: web.HOSTNAMEREPLACE
    container_name: web.HOSTNAMEREPLACE
    command: web
    volumes:
      - ./artifacts/web/log:/var/log/1c
      - ./artifacts/web/www/a/:/var/www/a/
      - ./artifacts/web/www/int/:/var/www/int/
      - ./artifacts/web/conf/httpd.conf:/etc/httpd/conf/httpd.conf
      - ./mnt:/mnt
    depends_on:
      - srv
  
  site:
    image: fresh/site
    hostname: site.HOSTNAMEREPLACE
    container_name: site.HOSTNAMEREPLACE
    volumes:
      - ./artifacts/site/searchIndex:/var/www/content/searchIndex
      - ./artifacts/site/site_files:/var/www/content/site_files
      - ./mnt:/mnt
      - ../distr/postgresql.jar:/usr/local/tomcat/lib/postgresql.jdbc4.jar
      - ../conf/site/context.xml:/usr/local/tomcat/conf/context.xml
      - ../conf/site/server.xml:/usr/local/tomcat/conf/server.xml
      - ../images/site/distr/site/media:/var/www/content/media/
      - ../images/site/wait_site.sh:/wait_site.sh
    depends_on:
      - db

  forum:
    image: fresh/forum
    hostname: forum.HOSTNAMEREPLACE
    container_name: forum.HOSTNAMEREPLACE
    volumes:
      - ./artifacts/forum:/var/www/forum/mess_files
      - ./mnt:/mnt
      - ../distr/postgresql.jar:/usr/local/tomcat/lib/postgresql.jdbc4.jar
      - ../conf/forum/context.xml:/usr/local/tomcat/conf/context.xml
      - ../conf/forum/server.xml:/usr/local/tomcat/conf/server.xml
    depends_on:
      - db

  gate:
    image: fresh/gate
    hostname: gate.HOSTNAMEREPLACE
    container_name: gate.HOSTNAMEREPLACE
    volumes: 
      - ./mnt:/mnt
    depends_on:
      - srv