Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Docker override config from env variables #8326

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions bin/container_daemon
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
set -e
user=ipfs
repo="$IPFS_PATH"
ipfsEnvPrefix="IPFSCONFIG"

if [ `id -u` -eq 0 ]; then
echo "Changing user to $user"
Expand All @@ -25,6 +26,27 @@ else
ipfs config Addresses.API /ip4/0.0.0.0/tcp/5001
ipfs config Addresses.Gateway /ip4/0.0.0.0/tcp/8080

# Set config from ENV variables
# Some examples are:
#
# IPFSCONFIG_Swarm_EnableAutoRelay=true
# IPFSCONFIG_Addresses_Swarm=[\"/ip4/0.0.0.0/tcp/4001\",\"/ip6/::/tcp/4001\"]
env | \
while IFS='=' read -r name value; do
# Since we don't have extended pattern in busybox, will use grep
if echo $name | grep -qxwE "${ipfsEnvPrefix}(_[a-zA-Z0-9]+)+" ; then
removePrefix=${name#$ipfsEnvPrefix*}
replaceToDot=${removePrefix//_/.}
ipfsConfigArg=${replaceToDot:1}

# Inform user what we are doing, since it could be
# a potential vector for command injections
set -x
ipfs config --json $ipfsConfigArg $value
{ set +x; } 2>/dev/null
fi
done

# Set up the swarm key, if provided

SWARM_KEY_FILE="$repo/swarm.key"
Expand Down