Make a separate script launcher.sh for the entry point, it allows

- passing args to the pybitmessage
  - setting API username and password through env
This commit is contained in:
Lee Miller 2022-03-23 21:50:40 +02:00 committed by Lee Miller
parent 8a9899c9df
commit 3b060d84b9
Signed by untrusted user: lee.miller
GPG Key ID: 4F97A5EA88F4AB63
2 changed files with 19 additions and 9 deletions

View File

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

16
packages/docker/launcher.sh Executable file
View File

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