Skip to content
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
6 changes: 5 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ LABEL maintainer="Steven Allen <steven@stebalien.com>"
RUN apt-get update && apt-get install -y \
libssl-dev \
ca-certificates \
fuse
fuse \
bash-static

ENV SRC_DIR /go-ipfs

Expand Down Expand Up @@ -72,6 +73,9 @@ COPY --from=0 /lib/*-linux-gnu*/libdl.so.2 /lib/
COPY --from=0 /usr/lib/*-linux-gnu*/libssl.so* /usr/lib/
COPY --from=0 /usr/lib/*-linux-gnu*/libcrypto.so* /usr/lib/

# Bash shell for ERR signals
COPY --from=0 /bin/bash-static /bin/bash

# Swarm TCP; should be exposed to the public
EXPOSE 4001
# Swarm UDP; should be exposed to the public
Expand Down
22 changes: 21 additions & 1 deletion bin/container_daemon
Original file line number Diff line number Diff line change
@@ -1,8 +1,22 @@
#!/bin/sh
#!/bin/bash
set -e
user=ipfs
repo="$IPFS_PATH"

init_scripts() {
trap 'kill $$' ERR # Kill parent if init fail
local scripts_path=$1

if [ -d ${scripts_path} ]; then
for script in ${scripts_path}/*.sh; do
echo "==== Running $script"
# Prevent failure if no +x is set on file
cat $script | sh -e
done
fi

}

if [ `id -u` -eq 0 ]; then
echo "Changing user to $user"
# ensure folder is writable
Expand Down Expand Up @@ -51,6 +65,12 @@ else
# Unset the swarm key file variable
unset IPFS_SWARM_KEY_FILE

# Pre-hook init with scripts
init_scripts /docker-prehook.d

# Post-hook init scripts
{ sleep 10; init_scripts /docker-posthook.d ; } &
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Separate stage after sleeping for 10 seconds feels brittle. Could not be enough if my node runs on slow CI and takes longer time to init/start etc.

I feel we don't need a separate directory with posthooks executed after a hardcoded delay. If anything, we would be waiting for node to start (eg. by probing /api/v0/id on the API port etc).


fi

exec ipfs "$@"