From 5b0cb901cb8422a7a03599b8e349679e46d24d60 Mon Sep 17 00:00:00 2001 From: Lakshya Singh Date: Tue, 26 Sep 2023 00:40:53 +0530 Subject: [PATCH] feat: allow docker compose overrides - use file override to handle multiple networks - expose and map only required ports - name containers differently - add environment for chain variable - dont expose ports in image Signed-off-by: Lakshya Singh --- bitcoind/Dockerfile | 2 -- docker-compose.mainnet.yml | 25 +++++++++++++++++++++++++ docker-compose.regtest.yml | 25 +++++++++++++++++++++++++ docker-compose.testnet.yml | 10 ++++++++++ docker-compose.yml | 34 ++++++++-------------------------- 5 files changed, 68 insertions(+), 28 deletions(-) create mode 100644 docker-compose.mainnet.yml create mode 100644 docker-compose.regtest.yml create mode 100644 docker-compose.testnet.yml diff --git a/bitcoind/Dockerfile b/bitcoind/Dockerfile index 07f761c..feb830d 100644 --- a/bitcoind/Dockerfile +++ b/bitcoind/Dockerfile @@ -121,8 +121,6 @@ RUN chmod +x /healthcheck.sh VOLUME ["${BITCOIN_DATA}"] -EXPOSE 8332 8333 18332 18333 18444 - RUN mkdir -p "${BITCOIN_DATA}" RUN chown -R bitcoin:bitcoin "${BITCOIN_DATA}" diff --git a/docker-compose.mainnet.yml b/docker-compose.mainnet.yml new file mode 100644 index 0000000..6806566 --- /dev/null +++ b/docker-compose.mainnet.yml @@ -0,0 +1,25 @@ +version: "3.8" +name: main +services: + bitcoin-core: + container_name: bitcoind-main + expose: + - 8332 + ports: + - 8333:8333 + environment: + - BITCOIN_CHAIN=main + + core-lightning: + container_name: lightningd-main + command: + - --conf=/home/lightning/.lightning/main-config + - --bitcoin-rpcconnect=bitcoind + expose: + - 9735 + ports: + - 9735:9735 + env_file: + - ./assets/main-env + environment: + - BITCOIN_CHAIN=main \ No newline at end of file diff --git a/docker-compose.regtest.yml b/docker-compose.regtest.yml new file mode 100644 index 0000000..46134c6 --- /dev/null +++ b/docker-compose.regtest.yml @@ -0,0 +1,25 @@ +version: "3.8" +name: regtest +services: + bitcoin-core: + container_name: bitcoind-regtest + expose: + - 38332 + ports: + - 38333:38333 + environment: + - BITCOIN_CHAIN=regtest + + core-lightning: + container_name: lightningd-regtest + command: + - --conf=/home/lightning/.lightning/regtest-config + - --bitcoin-rpcconnect=bitcoind + expose: + - 19846 + ports: + - 19846:19846 + env_file: + - ./assets/regtest-env + environment: + - BITCOIN_CHAIN=regtest \ No newline at end of file diff --git a/docker-compose.testnet.yml b/docker-compose.testnet.yml new file mode 100644 index 0000000..250495a --- /dev/null +++ b/docker-compose.testnet.yml @@ -0,0 +1,10 @@ +version: "3.8" +name: testnet +services: + bitcoin-core: + ports: + - 18333:18333 + + core-lightning: + ports: + - 19735:19735 \ No newline at end of file diff --git a/docker-compose.yml b/docker-compose.yml index b1e6ddb..4ef7ef5 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -4,22 +4,11 @@ services: build: dockerfile: ./bitcoind/Dockerfile image: bitcoind - container_name: bitcoind - command: - - --testnet - - -pid=/home/bitcoin/.bitcoin/testnet3/bitcoind-testnet.pid + container_name: bitcoind-test volumes: - data:/home/bitcoin/.bitcoin expose: - - 8332 - - 8333 - 18332 - - 18333 - - 18444 - ports: - - 8333:8333 - - 18333:18333 - - 38333:38333 networks: LN_testing: aliases: @@ -31,31 +20,24 @@ services: build: dockerfile: ./lightningd/Dockerfile image: lightningd - container_name: lightningd + container_name: lightningd-test command: - - --conf=/home/lightning/.lightning/testnet-config + - --conf=/home/lightning/.lightning/test-config - --bitcoin-rpcconnect=bitcoind - - --bind-addr=core-lightning:19735 - - --announce-addr=core-lightning:19735 volumes: - clightning:/home/lightning/.lightning expose: - - 9735 - - 9835 - ports: - - 9735:9735 - - 19735:19735 + - 19735 networks: - LN_testing - links: - - bitcoin-core:bitcoind depends_on: bitcoin-core: condition: service_healthy restart: true env_file: - - ./assets/testnet-env - + - ./assets/test-env + environment: + - BITCOIN_CHAIN=test volumes: data: @@ -66,4 +48,4 @@ volumes: external: true networks: - LN_testing: \ No newline at end of file + LN_testing: