Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add migration depending on architecture #105

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions src/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,12 @@
# 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 download migration script
COPY download_migration.sh /tmp/
RUN /tmp/download_migration.sh

ARG UPSTREAM_VERSION
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/
ENTRYPOINT ["/usr/local/bin/dappnode_entrypoint.sh"]
10 changes: 2 additions & 8 deletions src/dappnode_entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ user=ipfs
# IPFS_PATH=/data/ipfs
repo="$IPFS_PATH"

fs-repo-migrations

# 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"
Expand Down Expand Up @@ -55,14 +57,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
25 changes: 25 additions & 0 deletions src/download_migration.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#!/bin/sh

ARCHITECTURE=""
ARCH_URL=""

case $(uname -m) in
"x86_64") ARCHITECTURE="amd64";;
"i686") ARCHITECTURE="386";;
"aarch64") ARCHITECTURE="arm64";;
"armv7l") ARCHITECTURE="arm";;
*)
echo "Unsupported architecture: $(uname -m)"
exit 1
;;
esac

ARCH_URL="https://dist.ipfs.tech/fs-repo-migrations/v2.0.2/fs-repo-migrations_v2.0.2_linux-${ARCHITECTURE}.tar.gz"

echo "Architecture: ${ARCHITECTURE}"
echo "Downloading from URL: ${ARCH_URL}"

wget "${ARCH_URL}" && \
tar -xvf "fs-repo-migrations_v2.0.2_linux-${ARCHITECTURE}.tar.gz" && \
mv fs-repo-migrations/fs-repo-migrations /usr/local/bin/ && \
rm -rf "fs-repo-migrations_v2.0.2_linux-${ARCHITECTURE}.tar.gz" fs-repo-migrations
Loading