From e17de97c93aaea51cd4cfc97f8bfbff7423efc0b Mon Sep 17 00:00:00 2001 From: Andrew Camilleri Date: Tue, 4 Dec 2018 14:54:04 +0100 Subject: [PATCH] Isolate postgres and enable mysql & sqlite through docker --- .../docker-fragments/btcpayserver.yml | 2 -- .../docker-fragments/mysql.yml | 19 +++++++++++++++++++ .../docker-fragments/postgres.yml | 5 +++++ .../src/DockerComposition.cs | 7 +++++++ docker-compose-generator/src/Program.cs | 4 +++- 5 files changed, 34 insertions(+), 3 deletions(-) create mode 100644 docker-compose-generator/docker-fragments/mysql.yml diff --git a/docker-compose-generator/docker-fragments/btcpayserver.yml b/docker-compose-generator/docker-fragments/btcpayserver.yml index 9309a8b..8e34946 100644 --- a/docker-compose-generator/docker-fragments/btcpayserver.yml +++ b/docker-compose-generator/docker-fragments/btcpayserver.yml @@ -9,7 +9,6 @@ services: - "49392" environment: # BTCPay settings - BTCPAY_POSTGRES: User ID=postgres;Host=postgres;Port=5432;Database=btcpayserver${NBITCOIN_NETWORK:-regtest} BTCPAY_NETWORK: ${NBITCOIN_NETWORK:-regtest} BTCPAY_BIND: 0.0.0.0:49392 BTCPAY_EXTERNALURL: ${BTCPAY_PROTOCOL:-https}://${BTCPAY_HOST}/ @@ -19,7 +18,6 @@ services: BTCPAY_DEBUGLOG: btcpay.log links: - nbxplorer - - postgres volumes: - "btcpay_datadir:/datadir" - "nbxplorer_datadir:/root/.nbxplorer" diff --git a/docker-compose-generator/docker-fragments/mysql.yml b/docker-compose-generator/docker-fragments/mysql.yml new file mode 100644 index 0000000..0fde6c9 --- /dev/null +++ b/docker-compose-generator/docker-fragments/mysql.yml @@ -0,0 +1,19 @@ +version: "3" + +services: + mysql: + restart: unless-stopped + image: mysql:8.0 + volumes: + - "mysql_datadir:/var/lib/mysql" + environment: + MYSQL_ALLOW_EMPTY_PASSWORD: yes + + btcpayserver: + environment: + BTCPAY_POSTGRES: Server=mysql;Database=btcpayserver${NBITCOIN_NETWORK:-regtest};Uid=root;Pwd=;Port=3306; + links: + - mysql + +volumes: + mysql_datadir: \ No newline at end of file diff --git a/docker-compose-generator/docker-fragments/postgres.yml b/docker-compose-generator/docker-fragments/postgres.yml index d558564..49563b9 100644 --- a/docker-compose-generator/docker-fragments/postgres.yml +++ b/docker-compose-generator/docker-fragments/postgres.yml @@ -6,6 +6,11 @@ services: image: postgres:9.6.5 volumes: - "postgres_datadir:/var/lib/postgresql/data" + btcpayserver: + environment: + BTCPAY_POSTGRES: User ID=postgres;Host=postgres;Port=5432;Database=btcpayserver${NBITCOIN_NETWORK:-regtest} + links: + - postgres volumes: postgres_datadir: \ No newline at end of file diff --git a/docker-compose-generator/src/DockerComposition.cs b/docker-compose-generator/src/DockerComposition.cs index 8a924ed..050e39b 100644 --- a/docker-compose-generator/src/DockerComposition.cs +++ b/docker-compose-generator/src/DockerComposition.cs @@ -17,6 +17,12 @@ namespace DockerGenerator get; set; } + + public string SelectedDatabase + { + get; + set; + } public string SelectedLN { get; @@ -39,6 +45,7 @@ namespace DockerGenerator continue; composition.SelectedCryptos.Add(selectedCrypto.ToLowerInvariant()); } + composition.SelectedDatabase = (Environment.GetEnvironmentVariable("BTCPAYGEN_DATABASE") ?? "postgtres").ToLowerInvariant(); composition.SelectedProxy = (Environment.GetEnvironmentVariable("BTCPAYGEN_REVERSEPROXY") ?? "").ToLowerInvariant(); composition.SelectedLN = (Environment.GetEnvironmentVariable("BTCPAYGEN_LIGHTNING") ?? "").ToLowerInvariant(); composition.AdditionalFragments = (Environment.GetEnvironmentVariable("BTCPAYGEN_ADDITIONAL_FRAGMENTS") ?? "").ToLowerInvariant() diff --git a/docker-compose-generator/src/Program.cs b/docker-compose-generator/src/Program.cs index df4c0ad..8161fd4 100644 --- a/docker-compose-generator/src/Program.cs +++ b/docker-compose-generator/src/Program.cs @@ -51,7 +51,9 @@ namespace DockerGenerator } fragments.Add("btcpayserver"); fragments.Add("nbxplorer"); - fragments.Add("postgres"); + if(composition.SelectedDatabase != "sqlite"){ + fragments.Add(composition.SelectedDatabase); + } foreach (var crypto in CryptoDefinition.GetDefinitions()) { if (!composition.SelectedCryptos.Contains(crypto.Crypto))