Skip to content

Commit

Permalink
Merge pull request #104 from dappnode/pablo/run-migrations
Browse files Browse the repository at this point in the history
Add fs repo mnigrations
  • Loading branch information
pablomendezroyo authored Aug 10, 2023
2 parents 4d24d8b + 46b31cb commit 1f557af
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 18 deletions.
2 changes: 1 addition & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
13 changes: 13 additions & 0 deletions src/Dockerfile
Original file line number Diff line number Diff line change
@@ -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"]
19 changes: 2 additions & 17 deletions src/dappnode_entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 1f557af

Please sign in to comment.