#!/usr/bin/env bash

set -ex

# App Defaults
export WORKERS=${WORKERS-4}
export LOGFILE=${LOGFILE-/srv/log/web.log}
export PORT=${PORT-8000}

# alias docker links variables

# COUCHDB SERVICE
export COUCHDB_DNS_NAME="${COUCHDB_ENV_COUCHDB_DATABASE}"
export COUCHDB_DNS_USER="${COUCHDB_ENV_COUCHDB_USER}"
export COUCHDB_DNS_PASS="${COUCHDB_ENV_COUCHDB_PASS}"
export COUCHDB_DNS_HOST="http://${COUCHDB_PORT_5984_TCP_ADDR}:${COUCHDB_PORT_5984_TCP_PORT}"

# SMTP SERVICE
export EMAIL_HOST="${SMTP_PORT_25_TCP_ADDR}"
export EMAIL_PORT="${SMTP_PORT_25_TCP_PORT}"

# MYSQL SERVICE
export DATABASE_URL="mysql://${DB_USER}:${DB_PASS}@${MARIADB_PORT_3306_TCP_ADDR}:${MARIADB_PORT_3306_TCP_PORT}/${DB_NAME}"

echo "Exec'ing $@"
exec "$@"

#!/usr/bin/env bash

set -ex

# App Defaults
export WORKERS=${WORKERS-4}
export LOGFILE=${LOGFILE-/srv/log/web.log}
export PORT=${PORT-8000}

# alias docker links variables

# COUCHDB SERVICE
export COUCHDB_DNS_NAME="${COUCHDB_ENV_COUCHDB_DATABASE}"
export COUCHDB_DNS_USER="${COUCHDB_ENV_COUCHDB_USER}"
export COUCHDB_DNS_PASS="${COUCHDB_ENV_COUCHDB_PASS}"
export COUCHDB_DNS_HOST="http://${COUCHDB_PORT_5984_TCP_ADDR}:${COUCHDB_PORT_5984_TCP_PORT}"

# SMTP SERVICE
export EMAIL_HOST="${SMTP_PORT_25_TCP_ADDR}"
export EMAIL_PORT="${SMTP_PORT_25_TCP_PORT}"

# MYSQL SERVICE
export DATABASE_URL="mysql://${DB_USER}:${DB_PASS}@${DB_HOST-$MARIADB_PORT_3306_TCP_ADDR}:${DB_PORT-$MARIADB_PORT_3306_TCP_PORT}/${DB_NAME}"

echo "Exec'ing $@"
exec "$@"

Use DB_PORT / DB_HOST else Docker link variable
Use DB_PORT / DB_HOST else Docker link variable