I want to deploy staging and production/dev(for now on the same server). I am using distillery and edeliver with prod.secret.exs and environment variables. But neither environment variables or prod.secret.exs works the way I wanted. prod.secret.exs only works at compile time and environment variables are global. Any workaround I can make get some variables e.g database credentials and ports dynamically?
Env vars don’t have to be global, you can specify them for each OS processes separately. That is, if you run your two apps in different OS processes.
I dont know much about BEAM instances. but I think you mean using different LINK_SYS_CONFIG(ie. per beam process?) and here is what my .deliver/config looks like
BUILD_HOST="dev05api.haitracker.com"
BUILD_USER="tanweer"
BUILD_AT="/home/tanweer/app_build"
if [[ "$DEPLOY_ENVIRONMENT" = "staging" ]]; then
STAGING_HOSTS="dev05api.haitracker.com"
STAGING_USER="tanweer"
DELIVER_TO="/home/tanweer/staging/app_release"
elif [[ "$DEPLOY_ENVIRONMENT" = "production" ]]; then
PRODUCTION_HOSTS="dev05api.haitracker.com"
PRODUCTION_USER="tanweer"
DELIVER_TO="/home/tanweer/production/app_release"
fi
LINK_SYS_CONFIG="$DELIVER_TO/haitracker.config"
But now I am getting cat: /home/tanweer/production/app_release/haitracker/releases/0.1.3/sys.config: No such file or directory error. although it should look for /home/tanweer/production/app_release/haitracker.config file but it doesnt, (still looking for ...releases/0.1.3/sys.config, dont know if thats how its supposed to be.)
I’ve never used ediliver, but it probably already runs separate releases on separate vms, so you just need to specify env vars to be used for each separately.
Then try making .profile app-specific, I guess. You can create two user accounts on your machine, one for staging and one for production with each having their own .profile. But yeah, I wouldn’t use .profile for configuring apps.