Skip to content

Commit

Permalink
Merge pull request #172 from tomochain/feature/docker-bootnode
Browse files Browse the repository at this point in the history
Refactor bootnode docker
  • Loading branch information
thanhson1085 authored Sep 13, 2018
2 parents 42fcf0c + 4f70294 commit 7c7895a
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 3 deletions.
8 changes: 5 additions & 3 deletions Dockerfile.bootnode
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ RUN apk add --no-cache make gcc musl-dev linux-headers
ADD . /tomochain
RUN cd /tomochain && make bootnode

RUN chmod +x /tomochain/build/bin/bootnode

FROM alpine:latest

LABEL maintainer="etienne@tomochain.com"
Expand All @@ -13,10 +15,10 @@ WORKDIR /tomochain

COPY --from=builder /tomochain/build/bin/bootnode /usr/local/bin/bootnode

RUN chmod +x /usr/local/bin/bootnode
COPY docker/bootnode ./

EXPOSE 30301

ENTRYPOINT ["/usr/local/bin/bootnode"]
ENTRYPOINT ["./entrypoint.sh"]

CMD ["--help"]
CMD ["-verbosity", "6", "-nodekey", "bootnode.key", "--addr", ":30301"]
Empty file.
24 changes: 24 additions & 0 deletions docker/bootnode/entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#!/bin/sh -x

# file to env
for env in PRIVATE_KEY; do
file=$(eval echo "\$${env}_FILE")
if [[ -f $file ]] && [[ ! -z $file ]]; then
echo "Replacing $env by $file"
export $env=$(cat $file)
fi
done

# private key
if [[ ! -z "$PRIVATE_KEY" ]]; then
echo "$PRIVATE_KEY" > bootnode.key
elif [[ ! -f ./bootnode.key ]]; then
bootnode -genkey bootnode.key
fi

# dump address
address="enode://$(bootnode -nodekey bootnode.key -writeaddress)@[$(hostname -i)]:30301"

echo "$address" > ./bootnodes/bootnodes

exec bootnode "$@"

0 comments on commit 7c7895a

Please sign in to comment.