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