#!/bin/bash

set -e

DOMAIN=$(relation-get domain) || exit 1

## These are mainly to setup the correct web-hook
if [ "$MASTER_BASE_SERVICE_NAME" == "$DOMAIN" ]; then
    ## This is because the IP will be the docker container version
    USESSL=""
else
    USESSL="CMD_PROTOCOL_USESSL: 'true'"
fi

config-add "\
services:
  $MASTER_BASE_SERVICE_NAME:
    environment:
      CMD_DOMAIN: $DOMAIN
      $USESSL
"