Use config file in docker (#38)

* Use config file mounted in docker container to run squeakserver

* Fix test script to shut down at end

* Expose port in dockerfile

* Update main docker-compose to use config file
This commit is contained in:
Jonathan Zernik 2020-06-08 00:10:04 -07:00 committed by GitHub
parent 057d9495d4
commit 30034d35ab
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 48 additions and 73 deletions

22
docker/config.ini Normal file
View file

@ -0,0 +1,22 @@
[DEFAULT]
network=simnet
[lnd]
rpc_host=lnd
rpc_port=10009
[electrum]
rpc_host=
rpc_port=
rpc_user=
rpc_pass=
[server]
rpc_host=0.0.0.0
rpc_port=8774
[postgresql]
host=db
database=squeakserver
user=postgres
password=postgres

View file

@ -87,6 +87,7 @@ services:
volumes:
- shared:/rpc
- lnd_dir:/root/.lnd
- ./config.ini:/app/config.ini
ports:
- 8774:8774
- 18774:18774
@ -96,7 +97,6 @@ services:
- db
sysctls:
- net.ipv6.conf.all.disable_ipv6=0
entrypoint: ["./start-sqkserver.sh"]
volumes:
# btcctl and lnd containers.

View file

@ -32,9 +32,6 @@ RUN ./install-rpc.sh
RUN python3 setup.py install
# Copy the config file template.
COPY "docker/sqkserver/config.ini.sh" .
EXPOSE 8774
# Copy the entrypoint script.
COPY "docker/sqkserver/start-sqkserver.sh" .
RUN chmod +x start-sqkserver.sh
CMD ["runsqueakserver", "--config", "config.ini", "--log-level", "DEBUG", "run-server"]

View file

@ -1,66 +0,0 @@
#!/usr/bin/env bash
# exit from script if error was raised.
set -e
# error function is used within a bash function in order to send the error
# message directly to the stderr output and exit.
error() {
echo "$1" > /dev/stderr
exit 0
}
# return is used within bash function in order to return the value.
return() {
echo "$1"
}
# set_default function gives the ability to move the setting of default
# env variable from docker file to the script thereby giving the ability to the
# user override it durin container start.
set_default() {
# docker initialized env variables with blank string and we can't just
# use -z flag as usually.
BLANK_STRING='""'
VARIABLE="$1"
DEFAULT="$2"
if [[ -z "$VARIABLE" || "$VARIABLE" == "$BLANK_STRING" ]]; then
if [ -z "$DEFAULT" ]; then
error "You should specify default variable"
else
VARIABLE="$DEFAULT"
fi
fi
return "$VARIABLE"
}
# Set default variables if needed.
LND_HOST="lnd"
LND_PORT=10009
RPCUSER=$(set_default "$RPCUSER" "devuser")
RPCPASS=$(set_default "$RPCPASS" "devpass")
DEBUG=$(set_default "$DEBUG" "debug")
NETWORK=$(set_default "$NETWORK" "simnet")
CHAIN=$(set_default "$CHAIN" "bitcoin")
SQK_HOST="0.0.0.0"
SQK_PORT=8774
# Generate the config file.
chmod +x config.ini.sh
./config.ini.sh $NETWORK $LND_HOST $LND_PORT $SQK_HOST $SQK_PORT > config.ini
echo "config.ini:"
cat config.ini
echo "Starting to run the python server here...."
exec runsqueakserver \
"--config"="config.ini" \
"--log-level"="$DEBUG" \
run-server
# exec ls

22
itests/config.ini Normal file
View file

@ -0,0 +1,22 @@
[DEFAULT]
network=simnet
[lnd]
rpc_host=lnd
rpc_port=10009
[electrum]
rpc_host=
rpc_port=
rpc_user=
rpc_pass=
[server]
rpc_host=0.0.0.0
rpc_port=8774
[postgresql]
host=db
database=squeakserver
user=postgres
password=postgres

View file

@ -143,13 +143,13 @@ services:
volumes:
- shared_test:/rpc
- lnd_dir_sqkserver:/root/.lnd
- ./config.ini:/app/config.ini
links:
- "lnd_sqkserver:lnd"
depends_on:
- db
sysctls:
- net.ipv6.conf.all.disable_ipv6=0
entrypoint: ["./start-sqkserver.sh"]
test:
image: test