Browse Source

added env var $IPFS_SWARM_ADDRS to configure swarm addrs:ports

Fabian Peter Hammerle 5 years ago
parent
commit
9194dac2f1
3 changed files with 25 additions and 5 deletions
  1. 2 1
      Dockerfile
  2. 18 4
      README.md
  3. 5 0
      entrypoint.sh

+ 2 - 1
Dockerfile

@@ -3,7 +3,7 @@ FROM alpine:3.8
 RUN find / -xdev -type f -perm /u+s -exec chmod --changes u-s {} \; \
     && find / -xdev -type f -perm /g+s -exec chmod --changes g-s {} \;
 
-RUN apk add tini
+RUN apk add tini jq
 
 # $ readelf -l /tmp/go-ipfs/ipfs | grep 'program interpreter'
 #   [Requesting program interpreter: /lib64/ld-linux-x86-64.so.2]
@@ -23,6 +23,7 @@ RUN wget -O- https://dist.ipfs.io/go-ipfs/v${IPFS_VERSION}/go-ipfs_v${IPFS_VERSI
     && rm -r /tmp/go-ipfs
 
 ENV IPFS_INIT_PROFILE server
+ENV IPFS_SWARM_ADDRS "/ip4/0.0.0.0/tcp/4001"
 ENV IPFS_BOOTSTRAP_ADD ""
 COPY entrypoint.sh /
 RUN chmod a=rx /entrypoint.sh

+ 18 - 4
README.md

@@ -6,13 +6,11 @@ docker hub: https://hub.docker.com/r/fphammerle/ipfs/
 
 ipfs config guide: https://docs.ipfs.io/guides/examples/config/
 
-## example: short
-
 ```sh
 docker run --name ipfs fphammerle/ipfs
 ```
 
-## example: restart automatically
+## restart automatically
 
 ```sh
 docker run --name ipfs \
@@ -21,7 +19,23 @@ docker run --name ipfs \
     fphammerle/ipfs:latest
 ```
 
-## example: add bootstrap peers
+## change swarm listening addresses
+
+```sh
+docker run --name ipfs \
+    --env IPFS_SWARM_ADDRS="/ip4/0.0.0.0/tcp/4021 /ip6/::/tcp/4021" \
+    fphammerle/ipfs:latest
+```
+
+## disable swarm listener
+
+```sh
+docker run --name ipfs \
+    --env IPFS_SWARM_ADDRS="" \
+    fphammerle/ipfs:latest
+```
+
+## add bootstrap peers
 
 ```sh
 docker run --name ipfs \

+ 5 - 0
entrypoint.sh

@@ -4,6 +4,11 @@ if [ ! -e "$IPFS_PATH/config" ]; then
     (set -x; ipfs init --profile $IPFS_INIT_PROFILE)
 fi
 
+if [ "$IPFS_SWARM_ADDRS" != "default" ]; then
+    addrs_json=$(jq --null-input --compact-output '$ARGS.positional' --args $IPFS_SWARM_ADDRS)
+    (set -x; ipfs config --json Addresses.Swarm "$addrs_json")
+fi
+
 if [ ! -z "$IPFS_BOOTSTRAP_ADD" ]; then
     (set -x; ipfs bootstrap add -- $IPFS_BOOTSTRAP_ADD)
 fi