#!/bin/bash

set -e

PASSWORD="$(relation-get password)"
USER="$(relation-get user)"
DBNAME="$(relation-get dbname)"
HOST="$(relation-get host)"
PORT="$(relation-get port)"


config-add "\
services:
  $MASTER_BASE_SERVICE_NAME:
    environment:
      DATABASE_URL: \"postgres://$USER:$PASSWORD@$HOST:$PORT/$DBNAME\"
"


info "Configured $SERVICE_NAME code for $HOST:$PORT access."