From df7c1fcc97ef1ecec3cefc23f7ceaaf77f9b5079 Mon Sep 17 00:00:00 2001 From: Antti Kaihola Date: Sat, 15 Sep 2018 21:56:12 +0300 Subject: [PATCH 1/2] docker: allow IPFS_PROFILE to choose the profile for `ipfs init` License: MIT Signed-off-by: Antti Kaihola --- README.md | 4 ++++ bin/container_daemon | 6 +++++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 647b4de2e..af4e89e0d 100644 --- a/README.md +++ b/README.md @@ -317,6 +317,10 @@ Stop the running container: docker stop ipfs_host +When starting a container running ipfs for the first time with an empty data directory, it will call `ipfs init` to initialize configuration files and generate a new keypair. At this time, you can choose which profile to apply using the `IPFS_PROFILE` environment variable: + + docker run -d --name ipfs_host -e IPFS_PROFILE=server -v $ipfs_staging:/export -v $ipfs_data:/data/ipfs -p 4001:4001 -p 127.0.0.1:8080:8080 -p 127.0.0.1:5001:5001 ipfs/go-ipfs:latest + ### Troubleshooting If you have previously installed IPFS before and you are running into problems getting a newer version to work, try deleting (or backing up somewhere else) your IPFS config directory (~/.ipfs by default) and rerunning `ipfs init`. This will reinitialize the config file to its defaults and clear out the local datastore of any bad entries. diff --git a/bin/container_daemon b/bin/container_daemon index 81be54dd2..28e69cad1 100755 --- a/bin/container_daemon +++ b/bin/container_daemon @@ -17,7 +17,11 @@ ipfs version if [ -e "$repo/config" ]; then echo "Found IPFS fs-repo at $repo" else - ipfs init + case $IPFS_PROFILE in + "") INIT_ARGS= ;; + *) INIT_ARGS=--profile=$IPFS_PROFILE ;; + esac + ipfs init $INIT_ARGS ipfs config Addresses.API /ip4/0.0.0.0/tcp/5001 ipfs config Addresses.Gateway /ip4/0.0.0.0/tcp/8080 fi From 821982e96a3b98903e15f371fdfafb624f1bd179 Mon Sep 17 00:00:00 2001 From: Antti Kaihola Date: Wed, 26 Sep 2018 10:59:16 +0300 Subject: [PATCH 2/2] docker: Quote `ipfs init` args in the container_daemon shell script License: MIT Signed-off-by: Antti Kaihola --- bin/container_daemon | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/bin/container_daemon b/bin/container_daemon index 28e69cad1..3a0c5fd55 100755 --- a/bin/container_daemon +++ b/bin/container_daemon @@ -17,9 +17,9 @@ ipfs version if [ -e "$repo/config" ]; then echo "Found IPFS fs-repo at $repo" else - case $IPFS_PROFILE in - "") INIT_ARGS= ;; - *) INIT_ARGS=--profile=$IPFS_PROFILE ;; + case "$IPFS_PROFILE" in + "") INIT_ARGS="" ;; + *) INIT_ARGS="--profile=$IPFS_PROFILE" ;; esac ipfs init $INIT_ARGS ipfs config Addresses.API /ip4/0.0.0.0/tcp/5001