Skip to content
Merged
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
21 changes: 21 additions & 0 deletions src/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,27 @@
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 ARCH=$(uname -m) && \
if [ "$ARCH" = "x86_64" ]; then \
ARCH="amd64"; \
elif [ "$ARCH" = "aarch64" ]; then \
ARCH="arm64"; \
else \
echo "Unsupported architecture: $ARCH" && exit 1; \
fi && \
wget https://dist.ipfs.tech/fs-repo-migrations/v2.0.2/fs-repo-migrations_v2.0.2_linux-$ARCH.tar.gz && \
tar -xvf fs-repo-migrations_v2.0.2_linux-$ARCH.tar.gz && \
mv fs-repo-migrations/fs-repo-migrations /usr/local/bin/ && \
rm -rf fs-repo-migrations_v2.0.2_linux-$ARCH.tar.gz fs-repo-migrations

FROM ipfs/kubo:${UPSTREAM_VERSION}

# Copy the fs-repo-migrations binary from the intermediate container
COPY --from=fs-repo-migrations /usr/local/bin/fs-repo-migrations /usr/local/bin/fs-repo-migrations

COPY entrypoint.sh /usr/local/bin/entrypoint.sh
RUN chmod +x /usr/local/bin/entrypoint.sh

Expand Down
17 changes: 16 additions & 1 deletion src/entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ set -e
user=ipfs
repo="$IPFS_PATH"

echo "Starting IPFS entrypoint script"

if [ "$(id -u)" -eq 0 ]; then
echo "Changing user to $user"
# ensure folder is writable
Expand All @@ -12,10 +14,11 @@ if [ "$(id -u)" -eq 0 ]; then
exec gosu "$user" "$0" "$@"
fi

echo "Running as user: $(id -un)"

# 2nd invocation with regular user
ipfs version


if [ -e "$repo/config" ]; then
echo "Found IPFS fs-repo at $repo"
else
Expand Down Expand Up @@ -51,7 +54,19 @@ else
fi

# IMPORTANT: this is a copy of the original entrypoint to add dappnode custom config to inject our gateways
# In order to be able to execute config commands, the fs-repo-migrations must be run first
echo "Running fs-repo-migrations"
/usr/local/bin/fs-repo-migrations -y
echo "Running IPFS config commands"
ipfs config --json API.HTTPHeaders.Access-Control-Allow-Origin '["*"]'
ipfs config --json API.HTTPHeaders.Access-Control-Allow-Methods '["PUT", "GET", "POST"]'
ipfs config --json Gateway.PublicGateways '{"ipfs.dappnode": { "NoDNSLink": false, "Paths": [ "/ipfs" , "/ipns" ], "UseSubdomains": false }}'
# Add to bootstrap list the production Dappnode IPFS gateway
ipfs bootstrap add /ip4/65.109.51.31/tcp/4001/p2p/12D3KooWLdrSru7LzYY4YDcfnJsrJeshTQooR2j38NkGvoj2yADp
# Add to bootstrap list the dev Dappnode IPFS gateway
ipfs bootstrap add /ip4/167.86.114.131/tcp/4001/p2p/12D3KooWCAx5zWejUDotqc7dcvpvNstM9eZRdtdne1oXZ1DpdLFb
# list bootstrap peers
ipfs bootstrap list

find /container-init.d -maxdepth 1 -type f -iname '*.sh' -print0 | sort -z | xargs -n 1 -0 -r container_init_run

Expand Down