#!/bin/bash

set -e

PASSWORD="$(relation-get password)"
USER="$(relation-get user)"
DBNAME="$(relation-get dbname)"

config-add "\
services:
  $MASTER_BASE_SERVICE_NAME:
    environment:
      DB_HOST: \"$MASTER_TARGET_SERVICE_NAME\"
      DB_NAME: \"$DBNAME\"
      DB_USER: \"$USER\"
      DB_PASSWORD: \"$PASSWORD\"
"

info "Configured $SERVICE_NAME code for $TARGET_SERVICE_NAME access."