diff --git a/docker-compose.yml b/docker-compose.yml index eac8e54..e860c23 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -13,7 +13,7 @@ services: context: ./src args: UPSTREAM_VERSION: v0.22.0 - image: "ipfs.dnp.dappnode.eth:0.2.16" + image: "ipfs.dnp.dappnode.eth:0.2.20" restart: unless-stopped volumes: - "ipfsdnpdappnodeeth_export:/export" diff --git a/src/Dockerfile b/src/Dockerfile index 67edd11..4b49700 100644 --- a/src/Dockerfile +++ b/src/Dockerfile @@ -1,4 +1,17 @@ ARG UPSTREAM_VERSION + +# Create intermediate container for the fs-repo-migrations binary. Use a lightweight alpine image +FROM alpine:3.14.2 as fs-repo-migrations +# copy the migrations binary from the url https://dist.ipfs.tech/fs-repo-migrations/v2.0.2/fs-repo-migrations_v2.0.2_darwin-arm64.tar.gz +# to the container and extract it +RUN wget https://dist.ipfs.tech/fs-repo-migrations/v2.0.2/fs-repo-migrations_v2.0.2_linux-amd64.tar.gz && \ + tar -xvf fs-repo-migrations_v2.0.2_linux-amd64.tar.gz && \ + mv fs-repo-migrations/fs-repo-migrations /usr/local/bin/ && \ + rm -rf fs-repo-migrations_v2.0.2_linux-amd64.tar.gz fs-repo-migrations + + FROM ipfs/kubo:${UPSTREAM_VERSION} COPY dappnode_entrypoint.sh /usr/local/bin/ +COPY --from=fs-repo-migrations /usr/local/bin/fs-repo-migrations /usr/local/bin/ +USER ipfs ENTRYPOINT ["/usr/local/bin/dappnode_entrypoint.sh"] diff --git a/src/dappnode_entrypoint.sh b/src/dappnode_entrypoint.sh index f136307..064f5a5 100755 --- a/src/dappnode_entrypoint.sh +++ b/src/dappnode_entrypoint.sh @@ -3,18 +3,11 @@ # This is a copy of the original_entrypoint.sh script set -e -user=ipfs + # IPFS_PATH=/data/ipfs repo="$IPFS_PATH" -# If the user changes then the volumes could not be used and the ipfs init will fail -if [ $(id -u) -eq 0 ]; then - echo "Changing user to $user" - # ensure folder is writable - chown -R -- "$user" "$repo" - # restart script with new privileges - exec su-exec "$user" "$0" "$@" -fi +fs-repo-migrations -y # 2nd invocation with regular user ipfs version @@ -55,14 +48,6 @@ ipfs config --json Datastore.StorageMax "\"$DATASTORE_STORAGEMAX\"" ## Provides origin isolation between content roots: https://github.com/ipfs/kubo/blob/master/docs/config.md#gatewaypublicgateways-usesubdomains ipfs config --json Gateway.PublicGateways '{"ipfs.dappnode": { "NoDNSLink": false, "Paths": [ "/ipfs" , "/ipns" ], "UseSubdomains": true }}' -# Add handler -sigterm_handler() { - echo -e "Caught singal. Stopping ipfs service gracefully" - exit 0 -} - -trap 'sigterm_handler' TERM INT - # Possible values for EXTRA_OPTS (must have --): https://docs.ipfs.io/reference/cli/#ipfs-daemon # Join arguments with EXTRA_OPTS if var not empty. if [ ! -z $EXTRA_OPTS ]; then