Skip to content

Instantly share code, notes, and snippets.

@bhubr
Created July 26, 2020 02:12
Show Gist options
  • Save bhubr/82684767d94c9325469ccda9c1956d08 to your computer and use it in GitHub Desktop.
Save bhubr/82684767d94c9325469ccda9c1956d08 to your computer and use it in GitHub Desktop.
Import .env file to Dokku
#!/bin/bash
# Check number of args
# https://stackoverflow.com/q/18568706/
if [ "$#" -ne 2 ]; then
echo "Usage: import-env.sh <env-file> <dokku-app>"
fi
ENV_FILE=$1
DOKKU_APP=$2
# https://www.tutorialkart.com/bash-shell-scripting/bash-split-string/
IFS='='
# https://stackoverflow.com/q/19331497/
cat $ENV_FILE | while read line; do
read -ra ADDR <<< "$line"
dokku config:set --no-restart $DOKKU_APP "${ADDR[0]}"="${ADDR[1]}"
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment