Browse Source

expose ipfs api port

known problem: webui at http://localhost:5001/webui/ is broken
https://github.com/ipfs-shipyard/ipfs-webui/issues/997#issuecomment-485379731
Fabian Peter Hammerle 5 years ago
parent
commit
648712f585
3 changed files with 15 additions and 4 deletions
  1. 8 4
      Dockerfile
  2. 1 0
      docker-compose.yml
  3. 6 0
      entrypoint.sh

+ 8 - 4
Dockerfile

@@ -22,15 +22,19 @@ RUN wget -O- https://dist.ipfs.io/go-ipfs/v${IPFS_VERSION}/go-ipfs_v${IPFS_VERSI
     && mv /tmp/go-ipfs/ipfs /usr/local/bin \
     && 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 ""
+ENV IPFS_INIT_PROFILE=server \
+    IPFS_API_ADDR=/ip4/0.0.0.0/tcp/5001 \
+    IPFS_SWARM_ADDRS=/ip4/0.0.0.0/tcp/4001 \
+    IPFS_BOOTSTRAP_ADD=
 COPY entrypoint.sh /
 RUN chmod a=rx /entrypoint.sh
 ENTRYPOINT ["/sbin/tini", "--", "/entrypoint.sh"]
 
 USER ipfs
+# swarm
 EXPOSE 4001/tcp
-# ipfs http gateway
+# api & webgui
+EXPOSE 5001/tcp
+# http gateway
 EXPOSE 8080/tcp
 CMD ["ipfs", "daemon"]

+ 1 - 0
docker-compose.yml

@@ -11,6 +11,7 @@ services:
     - ipfs_repo:/ipfs-repo:rw
     ports:
     - '4001:4001'
+    - '127.0.0.1:5001:5001'
     security_opt: ['no-new-privileges']
     restart: unless-stopped
 

+ 6 - 0
entrypoint.sh

@@ -6,6 +6,12 @@ if [ ! -e "$IPFS_CONFIG_PATH" ]; then
     (set -x; ipfs init --empty-repo --profile $IPFS_INIT_PROFILE)
 fi
 
+if [ "$IPFS_API_ADDR" != "default" ]; then
+    tmp=$(mktemp)
+    (set -x; jq '.Addresses.API = $ARGS.positional[0]' --args "$IPFS_API_ADDR" <"$IPFS_CONFIG_PATH" >$tmp)
+    mv $tmp "$IPFS_CONFIG_PATH"
+fi
+
 if [ "$IPFS_SWARM_ADDRS" != "default" ]; then
     # + ipfs config --json Addresses.Swarm '["/ip4/0.0.0.0/tcp/4001"]'
     # Error: api not running