Merge pull request #172 from tomochain/feature/docker-bootnode

Refactor bootnode docker
This commit is contained in:
Nguyen Sy Thanh Son 2018-09-13 09:22:39 +07:00 committed by GitHub
commit 7c7895a8d3
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 29 additions and 3 deletions

View file

@ -5,6 +5,8 @@ RUN apk add --no-cache make gcc musl-dev linux-headers
ADD . /tomochain ADD . /tomochain
RUN cd /tomochain && make bootnode RUN cd /tomochain && make bootnode
RUN chmod +x /tomochain/build/bin/bootnode
FROM alpine:latest FROM alpine:latest
LABEL maintainer="etienne@tomochain.com" LABEL maintainer="etienne@tomochain.com"
@ -13,10 +15,10 @@ WORKDIR /tomochain
COPY --from=builder /tomochain/build/bin/bootnode /usr/local/bin/bootnode COPY --from=builder /tomochain/build/bin/bootnode /usr/local/bin/bootnode
RUN chmod +x /usr/local/bin/bootnode COPY docker/bootnode ./
EXPOSE 30301 EXPOSE 30301
ENTRYPOINT ["/usr/local/bin/bootnode"] ENTRYPOINT ["./entrypoint.sh"]
CMD ["--help"] CMD ["-verbosity", "6", "-nodekey", "bootnode.key", "--addr", ":30301"]

View file

24
docker/bootnode/entrypoint.sh Executable file
View file

@ -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 "$@"