From 3b060d84b941ab065ea32ddd7cf8e718f6e4f036 Mon Sep 17 00:00:00 2001 From: "lee.miller" Date: Wed, 23 Mar 2022 21:50:40 +0200 Subject: [PATCH] Make a separate script launcher.sh for the entry point, it allows - passing args to the pybitmessage - setting API username and password through env --- Dockerfile | 12 +++--------- packages/docker/launcher.sh | 16 ++++++++++++++++ 2 files changed, 19 insertions(+), 9 deletions(-) create mode 100755 packages/docker/launcher.sh diff --git a/Dockerfile b/Dockerfile index 89ab8cf5..b409d27a 100644 --- a/Dockerfile +++ b/Dockerfile @@ -16,6 +16,7 @@ ENV BITMESSAGE_HOME ${HOME} WORKDIR ${HOME} ADD . ${HOME} +COPY packages/docker/launcher.sh /usr/bin/ # Install RUN pip2 install jsonrpclib . @@ -32,12 +33,5 @@ USER bitmessage # Generate default config RUN pybitmessage -t -# Setup environment -RUN APIPASS=$(tr -dc a-zA-Z0-9 < /dev/urandom | head -c32 && echo) \ - && echo "\napiusername: api\napipassword: $APIPASS" \ - && sed -ie "s|\(apiinterface = \).*|\10\.0\.0\.0|g" keys.dat \ - && sed -ie "s|\(apivariant = \).*|\1json|g" keys.dat \ - && sed -ie "s|\(apiusername = \).*|\1api|g" keys.dat \ - && sed -ie "s|\(apipassword = \).*|\1$APIPASS|g" keys.dat - -CMD ["pybitmessage", "-d"] +ENTRYPOINT ["launcher.sh"] +CMD ["-d"] diff --git a/packages/docker/launcher.sh b/packages/docker/launcher.sh new file mode 100755 index 00000000..c0e48855 --- /dev/null +++ b/packages/docker/launcher.sh @@ -0,0 +1,16 @@ +#!/bin/sh + +# Setup the environment for docker container +APIUSER=${USER:-api} +APIPASS=${PASSWORD:-$(tr -dc a-zA-Z0-9 < /dev/urandom | head -c32 && echo)} + +echo "\napiusername: $APIUSER\napipassword: $APIPASS" + +sed -i -e "s|\(apiinterface = \).*|\10\.0\.0\.0|g" \ + -e "s|\(apivariant = \).*|\1json|g" \ + -e "s|\(apiusername = \).*|\1$APIUSER|g" \ + -e "s|\(apipassword = \).*|\1$APIPASS|g" \ + -e "s|apinotifypath = .*||g" ${BITMESSAGE_HOME}/keys.dat + +# Run +exec pybitmessage "$@"