diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..09431e5 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,9 @@ +FROM python:3 +ENV APP_PATH=/srv/python-teos +VOLUME ["~/.teos"] +WORKDIR /srv +RUN mkdir ~/.teos && git clone https://github.com/aljazceru/python-teos.git && cd python-teos && pip install -r requirements.txt && python generate_keys.py -d ~/.teos +ENV PYTHONPATH=$APP_PATH +WORKDIR /srv/python-teos +EXPOSE 9814/tcp +ENTRYPOINT [ "/srv/python-teos/entrypoint.sh" ] diff --git a/README.md b/README.md index 70b6043..fe98ee2 100644 --- a/README.md +++ b/README.md @@ -37,6 +37,14 @@ The configuration includes, amongst others, where your data folder is placed, wh To run `teos` you need a set of keys (to sign appointments) stored in your data directory. You can follow [generate keys](#generate-keys) to generate them. +## Running `teos` as a docker container +`teos` container can be build from Dockerfile attached to the repo. ENV variables are optional, if not set defaults are used. + + git clone https://github.com/talaia-labs/python-teos + cd python-teos + docker build . -t teos + docker run -it -e BTC_RPC_USER= -e BTC_RPC_PASSWD= -e BTC_RPC_HOST= -e BTC_RPC_PORT= -p 9814:9814/tcp teos + ### Configuration file and command line parameters To change the configuration defaults you can: @@ -122,4 +130,4 @@ cp ~/.teos/teos_pk.der ~/.teos_cli/teos_pk.der ``` ## Contributing -Refer to [CONTRIBUTING.md](CONTRIBUTING.md) \ No newline at end of file +Refer to [CONTRIBUTING.md](CONTRIBUTING.md) diff --git a/entrypoint.sh b/entrypoint.sh new file mode 100755 index 0000000..a82b8b1 --- /dev/null +++ b/entrypoint.sh @@ -0,0 +1,30 @@ +#!/bin/bash + +START_COMMAND="/usr/local/bin/python3 -m teos.teosd " + +if [[ ! -z ${BTC_RPC_USER} ]]; then + START_COMMAND=$START_COMMAND" --btcrpcuser=""$BTC_RPC_USER" +fi + +if [[ ! -z ${BTC_RPC_HOST} ]]; then + START_COMMAND=$START_COMMAND" --btcrpcconnect=""$BTC_RPC_HOST" +fi + +if [[ ! -z ${BTC_RPC_PASSWD} ]]; then + START_COMMAND=$START_COMMAND" --btcrpcpassword=""$BTC_RPC_PASSWD" +fi + +if [[ ! -z ${BTC_NETWORK} ]]; then + START_COMMAND=$START_COMMAND" --btcnetwork=""$BTC_NETWORK" +fi + +if [[ ! -z ${API_CONNECT} ]]; then + START_COMMAND=$START_COMMAND" --apiconnect=""$API_CONNECT" +fi + +if [[ ! -z ${API_PORT} ]]; then + START_COMMAND=$START_COMMAND" --apiport=""$API_PORT" +fi + + +$START_COMMAND