Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
54 commits
Select commit Hold shift + click to select a range
6a8a8b5
feat(ln): initial version of ln-common-client modules
theborakompanioni Jul 19, 2023
e0a7de8
feat(ln): initial version of lightning-regtest modules
theborakompanioni Jul 24, 2023
cd3508a
feat(example): add run configuration for lightning-regtest example app
theborakompanioni Jul 27, 2023
6eaf479
chore(ln): prevent postgres vacuum warnings in lightning regtest env
theborakompanioni Jul 27, 2023
9352d7f
chore: remove unused class ShutdownHooks
theborakompanioni Jul 27, 2023
213116e
refactor: rename module ln-common-client to lightning-commons
theborakompanioni Jul 27, 2023
b236c2b
regtest(ln): speed up gossip and block sync for cln nodes
theborakompanioni Jul 28, 2023
dfa269c
regtest(ln): individual bitcoin rpcauth for regtest lightning nodes
theborakompanioni Jul 28, 2023
739baf5
cleanup: remove unused static var in RouteVerification
theborakompanioni Aug 1, 2023
ca04d52
chore(ln): add baseClient method to LnCommonClient
theborakompanioni Aug 1, 2023
ad3e293
refactor: outsource node info caching to inner class NodeInfos
theborakompanioni Aug 1, 2023
412a6d9
chore(ln): add 'connect' to LnCommonClient
theborakompanioni Aug 3, 2023
9f294aa
chore(ln): prefix messages of LightningCommonClient with Common*
theborakompanioni Aug 3, 2023
b1d7c71
chore(ln): add 'newAddress' to LightningCommonClient
theborakompanioni Aug 3, 2023
3d13fdf
chore(ln): add 'createInvoice' to LightningCommonClient
theborakompanioni Aug 3, 2023
70cb633
chore(ln): add 'listPeers' to LightningCommonClient
theborakompanioni Aug 3, 2023
31ab5c6
chore(ln): add 'openChannel' to LightningCommonClient
theborakompanioni Aug 3, 2023
7e67d15
fix(test): fix setup of lightning-regtest-example-app integration tests
theborakompanioni Aug 3, 2023
bf36ca9
chore(ln): add 'listUnspent' to LightningCommonClient
theborakompanioni Aug 3, 2023
71c1303
chore(ln): add 'listPeerChannels' to LightningCommonClient
theborakompanioni Aug 3, 2023
d64e448
chore(ln): add remote balance to PeerChannel message
theborakompanioni Aug 4, 2023
32facfa
fix(ln): fix num pending channels in common clients
theborakompanioni Aug 4, 2023
15d38cb
chore(ln): add 'pay' to LightningCommonClient
theborakompanioni Aug 4, 2023
206701f
chore(ln): add 'lookupInvoice' to LightningCommonClient
theborakompanioni Aug 4, 2023
a39ddf1
chore(ln): add 'lookupPayment' to LightningCommonClient
theborakompanioni Aug 4, 2023
3876511
chore(test): cleanup lightning regtest devel test
theborakompanioni Aug 6, 2023
3ba1492
chore(ln): add lnd node to lightning devel setup
theborakompanioni Aug 29, 2023
d3e53d5
chore(ln): configure hostname and p2p port of nodes
theborakompanioni Aug 29, 2023
9678212
chore(ln): use faucet instead of block rewards to fund node wallets
theborakompanioni Aug 29, 2023
f8922f4
fix(ln): catch error if peer is already connected
theborakompanioni Aug 30, 2023
47c4cad
chore(ln): support route verification with common client
theborakompanioni Sep 5, 2023
ee06fdc
refactor: remove generics from LightningCommonClient
theborakompanioni Sep 13, 2023
42b5b11
build(deps): cln from v23.05.2 to v23.08 in regtest-setup-devel
theborakompanioni Sep 13, 2023
dd854de
build(deps): update cln testcontainer from v23.05 to v23.08
theborakompanioni Sep 13, 2023
9e4dcc5
chore(ln): add healthcheck for postgres container in docker-compose
theborakompanioni Sep 18, 2023
ea7f97b
chore(ln): add healthcheck for bitcoind container in docker-compose
theborakompanioni Sep 18, 2023
3f68429
chore(ln): add healthcheck for lnd container in docker-compose
theborakompanioni Sep 19, 2023
33fb74a
chore(ln): add healthcheck for cln container in docker-compose
theborakompanioni Sep 19, 2023
fb8d6ec
chore: do not publish new lightning modules for now
theborakompanioni Sep 19, 2023
7832d12
build(deps): update lnd to v0.17.0-beta in regtest-setup-devel
theborakompanioni Oct 9, 2023
c942c98
build(deps): update postgres to v16.0-alpine3.18 in regtest-setup-devel
theborakompanioni Oct 9, 2023
9c31105
dev(regtest): update lnd instance from v0.17.0-beta to v0.17.2-beta
theborakompanioni Dec 2, 2023
a6381a5
chore(ln): add sync warning to ln common client getinfo response
theborakompanioni Dec 2, 2023
415643a
chore(ln): prevent lnd from syning indefinitely by mining a single bl…
theborakompanioni Dec 2, 2023
2d27a28
fix: remove brackets in example application name
theborakompanioni Jan 11, 2024
b1a9494
dev(regtest): update lnd instance from v0.17.2-beta to v0.17.4-beta
theborakompanioni Mar 8, 2024
5c9ebea
dev(regtest): update lnd instance from v0.17.4-beta to v0.18.2-beta
theborakompanioni Oct 6, 2024
f7c24e5
dev(regtest): (partially) update cln to v24.08.1
theborakompanioni Oct 10, 2024
e5ed38f
dev(regtest): disallow deprecated apis (cln)
theborakompanioni Oct 10, 2024
17aff68
dev(regtest): disable dns (cln)
theborakompanioni Oct 10, 2024
76b8bd9
dev(regtest): update some cln instances to v24.11.1
theborakompanioni Jan 4, 2025
2695973
chore: include docker-compose in dev and test env
theborakompanioni Jan 18, 2025
eb8c1d6
chore: update to lightning-kmp after rebase
theborakompanioni Apr 2, 2025
88f1370
dev(docker): remove docker volumes in lightning tests
theborakompanioni Apr 13, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions .run/LightningRegtestExampleApplication.run.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<component name="ProjectRunConfigurationManager">
<configuration default="false" name="LightningRegtestExampleApplication" type="Application" factoryName="Application" nameIsGenerated="true">
<option name="MAIN_CLASS_NAME" value="org.tbk.lightning.regtest.example.LightningRegtestExampleApplication" />
<module name="bitcoin-spring-boot-starter.lightning-regtest.lightning-regtest-example-application.main" />
<option name="PROGRAM_PARAMETERS" value="--spring.profiles.active=development" />
<option name="WORKING_DIRECTORY" value="$PROJECT_DIR$/lightning-regtest/lightning-regtest-example-application" />
<extension name="coverage">
<pattern>
<option name="PATTERN" value="org.tbk.lightning.regtest.example.*" />
<option name="ENABLED" value="true" />
</pattern>
</extension>
<method v="2">
<option name="Make" enabled="true" />
</method>
</configuration>
</component>
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,7 @@ BitcoinExtendedClient bitcoinRegtestClient(RpcConfig rpcConfig) {

boolean isRegtest = configuredNetworkId.equals(requiredNetworkId);
if (!isRegtest) {
String errorMessage = String.format("Bitcoin must be configured with network '%s' - got '%s'",
requiredNetworkId, configuredNetworkId);
String errorMessage = "Bitcoin must be configured with network '%s' - got '%s'".formatted(requiredNetworkId, configuredNetworkId);
throw new BeanCreationNotAllowedException("bitcoinRegtestClient", errorMessage);
}

Expand Down
1 change: 0 additions & 1 deletion bitcoin-regtest/bitcoin-regtest-core/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,4 @@ dependencies {

integTestImplementation project(':spring-testcontainer:spring-testcontainer-test')
integTestImplementation project(':spring-testcontainer:spring-testcontainer-bitcoind-starter')

}
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,11 @@

import static java.util.Objects.requireNonNull;


@SuppressFBWarnings(value = {"EI_EXPOSE_REP"}, justification = "on purpose")
public final class StaticCoinbaseRewardAddressSupplier implements CoinbaseRewardAddressSupplier {

private final Address address;

@SuppressFBWarnings(value = "EI_EXPOSE_REP2", justification = "class from external dependency")
public StaticCoinbaseRewardAddressSupplier(Address client) {
this.address = requireNonNull(client);
Expand All @@ -21,4 +20,3 @@ public Address get() {
return this.address;
}
}

Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ void itShouldPublishGenesisBlock() throws TimeoutException, ExecutionException,
genesisBlockPublishService.startAsync();
genesisBlockPublishService.awaitRunning(Duration.ofSeconds(10));

List<byte[]> blocks = blocksRef.get(10, TimeUnit.SECONDS);
List<byte[]> blocks = blocksRef.get(20, TimeUnit.SECONDS);

assertThat(blocks, hasSize(1));
assertThat(blocks.get(0), is(GenesisBlock.get().toByteArray()));
Expand Down
4 changes: 3 additions & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -369,6 +369,8 @@ subprojects {
// enable publishing for all subproject except for "example applications"
configure(subprojects.findAll { project -> project.subprojects.isEmpty() &&
!project.pluginManager.hasPlugin('org.springframework.boot') &&
project.name.indexOf('-example-application') < 0 }) {
project.name.indexOf('-example-application') < 0 &&
!project.name.startsWith('lightning-commons-') &&
!project.name.startsWith('lightning-regtest-') }) {
apply from: "${project.rootDir}/publish.gradle"
}
3 changes: 3 additions & 0 deletions changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- autoconfig property prefix of bitcoin jsonrpc cache changed from "jsonrpc.cache" to "jsonrpc-cache"
- bitcoin-regtest-starter does not import testcontainer dependencies for bitcoin, electrumx and electrum-daemon automatically anymore

### Added
- module: initial version of modules `lightning-commons-client-*`

### Changed
- improved default specs for bitcoin jsonrpc client caches
- upgrade: update spring-boot from v3.1.0 to v3.1.4
Expand Down
50 changes: 50 additions & 0 deletions docker/regtest/lightning-regtest-setup-devel/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
Local Regtest Lightning Network Docker Setup
===

## Bitcoin

## Local Regtest Lightning Network
### Nodes
#### CLN 0 (app)
The lightning node controlled by the application.

#### CLN 1 (Alice)
A user lightning node with a direct channel to the app node.

#### CLN 2 (Bob)
A user lightning node with a direct channel to the app node.

#### CLN 3 (Charlie)
A user lightning node with a direct channel to Bob and a private channel to Erin.

#### CLN 4 (Dave)
A user lightning node _without_ channels.
This is node solely exists to test the specific behaviour when no route can be found.

#### CLN 5 (Erin)
A node with a single incoming private channel from Charlie.

#### LND 6 (Farid)
A user lightning node with a direct channel to Charlie.


### Channels
```mermaid
flowchart TB
app -->|16_777_215 sat| alice
app -->|8_388_607 sat| bob
bob -->|4_194_303 sat| charlie
farid -->|4_194_303 sat| bob
charlie -. private 2_097_151 sat .-> erin
app ~~~ dave
alice ~~~ dave
bob ~~~ dave
charlie ~~~ dave
erin ~~~ dave
farid ~~~ dave
```


## Resources
- Node Personas: https://en.wikipedia.org/wiki/Alice_and_Bob#Cast_of_characters
- Mermaid Flowchart: https://mermaid.js.org/syntax/flowchart.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
-----BEGIN PRIVATE KEY-----
MIGHAgEAMBMGByqGSM49AgEGCCqGSM49AwEHBG0wawIBAQQgXYu7d9TgoMJMSZ7h
u3OC3pIcdMPamt67+OjJTjLD0zmhRANCAAQnY8oKVvPhGTtsNh1/pOvAkSMREWnX
ZDNgYukgrbuvDoJtDmiubv7XyERb5+Lynyn11sTiMNsNu3uRvogm0nvo
-----END PRIVATE KEY-----
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
-----BEGIN CERTIFICATE-----
MIIBcDCCARegAwIBAgIIAT8Xud6bYGcwCgYIKoZIzj0EAwIwFjEUMBIGA1UEAwwL
Y2xuIFJvb3QgQ0EwIBcNNzUwMTAxMDAwMDAwWhgPNDA5NjAxMDEwMDAwMDBaMBYx
FDASBgNVBAMMC2NsbiBSb290IENBMFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAE
J2PKClbz4Rk7bDYdf6TrwJEjERFp12QzYGLpIK27rw6CbQ5orm7+18hEW+fi8p8p
9dbE4jDbDbt7kb6IJtJ76KNNMEswGQYDVR0RBBIwEIIDY2xugglsb2NhbGhvc3Qw
HQYDVR0OBBYEFGdgm965Fz8Boy+QC4VcfjPkI32/MA8GA1UdEwEB/wQFMAMBAf8w
CgYIKoZIzj0EAwIDRwAwRAIgKAuHASDF5NvIeBC6+cub55x3EafzlY81273lwPnE
ZGsCIDYXdvXtIVXgliItGCPux95/9AesKiO7zMg7BZwzm3b7
-----END CERTIFICATE-----
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
-----BEGIN PRIVATE KEY-----
MIGHAgEAMBMGByqGSM49AgEGCCqGSM49AwEHBG0wawIBAQQg+EzkF+0hjctnhlTC
NMs2zfouhYF1+Dm83QrRfVzdr8OhRANCAATqzv3qsEDMESI/y/8QUcQjyoFZGLzD
zprcwl5QMYrasuo8mkAK5TyGtz3uEj8I4mzXyS7sue85Stk6PCnfWmf9
-----END PRIVATE KEY-----
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
-----BEGIN CERTIFICATE-----
MIIBRTCB7KADAgECAgkAnI6iARFsYxkwCgYIKoZIzj0EAwIwFjEUMBIGA1UEAwwL
Y2xuIFJvb3QgQ0EwIBcNNzUwMTAxMDAwMDAwWhgPNDA5NjAxMDEwMDAwMDBaMBox
GDAWBgNVBAMMD2NsbiBncnBjIENsaWVudDBZMBMGByqGSM49AgEGCCqGSM49AwEH
A0IABOrO/eqwQMwRIj/L/xBRxCPKgVkYvMPOmtzCXlAxitqy6jyaQArlPIa3Pe4S
PwjibNfJLuy57zlK2To8Kd9aZ/2jHTAbMBkGA1UdEQQSMBCCA2NsboIJbG9jYWxo
b3N0MAoGCCqGSM49BAMCA0gAMEUCIF7s4Lm9dVWw4dCT+ytCcJMzOqW7UX2LqOEG
eB6llcfaAiEA/45KEZiP+z96eNKHLuBeb8yMUi7BRUMJ5vM8bTrdI3E=
-----END CERTIFICATE-----
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
j‡Ãñ³qjßšÚí ŸïbËNNIÎ!]¢X5È`^
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
-----BEGIN PRIVATE KEY-----
MIGHAgEAMBMGByqGSM49AgEGCCqGSM49AwEHBG0wawIBAQQglJQWbG4UHnzwM45k
qtnScyBWMb9SwQQpIbdjKlZwuTuhRANCAAQFVq5oq8U43x/0qrLsQNB/dA91Nl5t
fTKIjhCgbODJtyNZBzCvCZfV3SjiSWZVUzQ6ovOACXMOkURspDVlw8+0
-----END PRIVATE KEY-----
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
-----BEGIN CERTIFICATE-----
MIIBRDCB66ADAgECAggMDiolY5j7zjAKBggqhkjOPQQDAjAWMRQwEgYDVQQDDAtj
bG4gUm9vdCBDQTAgFw03NTAxMDEwMDAwMDBaGA80MDk2MDEwMTAwMDAwMFowGjEY
MBYGA1UEAwwPY2xuIGdycGMgU2VydmVyMFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcD
QgAEBVauaKvFON8f9Kqy7EDQf3QPdTZebX0yiI4QoGzgybcjWQcwrwmX1d0o4klm
VVM0OqLzgAlzDpFEbKQ1ZcPPtKMdMBswGQYDVR0RBBIwEIIDY2xugglsb2NhbGhv
c3QwCgYIKoZIzj0EAwIDSAAwRQIgVi+1vCRVxN5UAN3iI6tyZmSgHXQIRcWu25Dz
lKICU70CIQDIbCYTMsX+JK5f/Om/7xdWVbZsy4AUkLNiHXREUiIIZA==
-----END CERTIFICATE-----
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
ˆzþ¥ß‰.ÑùŽ{8ªYü /Wá±=P´2kô¬1
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
]"€–ÖA¹?Î
FÞ×e¾u߉'(GxÉÒ=u—§
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
tmÇ7 ADÁõß…ù[á¿]¬îDeßÑ{û»ó{qÂñ£
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
1ãBXdRIž‘hFª±o¾øN×àsÕàSGw·þ§
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
10æ½S¾Ó…5ïÑ"½½º\ñ59Ù"j)%ò\˜*”®
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
-----BEGIN PRIVATE KEY-----
MIGHAgEAMBMGByqGSM49AgEGCCqGSM49AwEHBG0wawIBAQQgvy/Up8PPYMOKvuWk
ZBzRUgrASUUQXxOKNDPoIT6qQOShRANCAASRbRUk5prLWlpWCvZfMhycJ0q90u73
kfw/haJlQx/nCEPhmqtIFg8sU/u7owioEgGCL+Vbk5sAioxDPDnN1JTU
-----END PRIVATE KEY-----
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
-----BEGIN CERTIFICATE-----
MIIBcTCCARegAwIBAgIICInqhhRSdIUwCgYIKoZIzj0EAwIwFjEUMBIGA1UEAwwL
Y2xuIFJvb3QgQ0EwIBcNNzUwMTAxMDAwMDAwWhgPNDA5NjAxMDEwMDAwMDBaMBYx
FDASBgNVBAMMC2NsbiBSb290IENBMFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAE
kW0VJOaay1paVgr2XzIcnCdKvdLu95H8P4WiZUMf5whD4ZqrSBYPLFP7u6MIqBIB
gi/lW5ObAIqMQzw5zdSU1KNNMEswGQYDVR0RBBIwEIIDY2xugglsb2NhbGhvc3Qw
HQYDVR0OBBYEFIV0UhSG6okIaidO3f9q12HvouTBMA8GA1UdEwEB/wQFMAMBAf8w
CgYIKoZIzj0EAwIDSAAwRQIgBDZCg1ksTH0barByrFANwShUoTHiKovmsQO8sG/e
VQICIQC7zJuaa/QvmD7b1XSz34A+geRK3Q3EsLlU4YNpodsKaw==
-----END CERTIFICATE-----
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
-----BEGIN PRIVATE KEY-----
MIGHAgEAMBMGByqGSM49AgEGCCqGSM49AwEHBG0wawIBAQQgRtzYq7kE4snLORoB
7YA2ABvOTn2t90/xmLzr8ofki8yhRANCAATh/XF+pI0laQ3IJKkchR3PxM0goDtP
ajRpKKAGfBQiipKLJE0OgWtdxO5dYvRRFutH/BFYKdB+5gJweKF/vQgh
-----END PRIVATE KEY-----
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
-----BEGIN CERTIFICATE-----
MIIBRjCB7KADAgECAgkAzCZRcesFmggwCgYIKoZIzj0EAwIwFjEUMBIGA1UEAwwL
Y2xuIFJvb3QgQ0EwIBcNNzUwMTAxMDAwMDAwWhgPNDA5NjAxMDEwMDAwMDBaMBox
GDAWBgNVBAMMD2NsbiBncnBjIENsaWVudDBZMBMGByqGSM49AgEGCCqGSM49AwEH
A0IABOH9cX6kjSVpDcgkqRyFHc/EzSCgO09qNGkooAZ8FCKKkoskTQ6Ba13E7l1i
9FEW60f8EVgp0H7mAnB4oX+9CCGjHTAbMBkGA1UdEQQSMBCCA2NsboIJbG9jYWxo
b3N0MAoGCCqGSM49BAMCA0kAMEYCIQDulTm56pbNb2hYRRoMvxo7dffvbsWIP7cS
CoBqPeAS/wIhALNVeVsEuXcgGbgFDjcV8xOljCE2a7lyq5A4sW9Q0YFM
-----END CERTIFICATE-----
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
-----BEGIN PRIVATE KEY-----
MIGHAgEAMBMGByqGSM49AgEGCCqGSM49AwEHBG0wawIBAQQgOoEzc7KLI1WmiMCe
vDfVWADAjavAA3EiBvSEyEWCCd6hRANCAAQfvDyYvADVA9NnLG7shorcDKLSTit1
HO/3Bxae5Rwkb56F3JgRQZRNL7QewzYkdcS+dOmpXJQXOqChblHLaF3x
-----END PRIVATE KEY-----
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
-----BEGIN CERTIFICATE-----
MIIBQzCB7KADAgECAgkAtS75duLswR8wCgYIKoZIzj0EAwIwFjEUMBIGA1UEAwwL
Y2xuIFJvb3QgQ0EwIBcNNzUwMTAxMDAwMDAwWhgPNDA5NjAxMDEwMDAwMDBaMBox
GDAWBgNVBAMMD2NsbiBncnBjIFNlcnZlcjBZMBMGByqGSM49AgEGCCqGSM49AwEH
A0IABB+8PJi8ANUD02csbuyGitwMotJOK3Uc7/cHFp7lHCRvnoXcmBFBlE0vtB7D
NiR1xL506alclBc6oKFuUctoXfGjHTAbMBkGA1UdEQQSMBCCA2NsboIJbG9jYWxo
b3N0MAoGCCqGSM49BAMCA0YAMEMCH3u9x++QrCVqm5Dd99QSZxgrNQqXJvAHQ8+G
2RKdj+kCIEPKSWo81qQApXjlGnQ0hCV7MM92jtgh9kAF2Jmtz4Hv
-----END CERTIFICATE-----
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
-----BEGIN CERTIFICATE-----
MIICJTCCAcugAwIBAgIRAPIqk/Gb1nTRlxBgK6HMi9owCgYIKoZIzj0EAwIwODEf
MB0GA1UEChMWbG5kIGF1dG9nZW5lcmF0ZWQgY2VydDEVMBMGA1UEAxMMMmE5NmZl
YzZiZDM3MB4XDTIzMDgwNTIxNTk0MFoXDTQ5MTIzMTIzNTk1OVowODEfMB0GA1UE
ChMWbG5kIGF1dG9nZW5lcmF0ZWQgY2VydDEVMBMGA1UEAxMMMmE5NmZlYzZiZDM3
MFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAE683eR4iT2DsCIyI9hgfK+62KU//1
Burm41ZZgd8tPtPqQnPun10Iw10HCg4U3brwQVnuUREJiG5k5/Sn5AxBcaOBtTCB
sjAOBgNVHQ8BAf8EBAMCAqQwEwYDVR0lBAwwCgYIKwYBBQUHAwEwDwYDVR0TAQH/
BAUwAwEB/zAdBgNVHQ4EFgQUmiOguB/zWQLgcRy5sR3nj+13I/MwWwYDVR0RBFQw
UoIMMmE5NmZlYzZiZDM3gglsb2NhbGhvc3SCBHVuaXiCCnVuaXhwYWNrZXSCB2J1
ZmNvbm6HBH8AAAGHEAAAAAAAAAAAAAAAAAAAAAGHBKwZAAUwCgYIKoZIzj0EAwID
SAAwRQIgaCwvi2UHTbkA54/77nwlaTY0EqdnkbG+dEoW4WD54mACIQC9GP1frTkG
oR0ebUBpQ6cJPxQ/5BCIG3I7D1AG/j5avA==
-----END CERTIFICATE-----
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
-----BEGIN EC PRIVATE KEY-----
MHcCAQEEIFLbJLk5tErs0mZh1+1esClqINqlCOIQO97c0GB0m9uQoAoGCCqGSM49
AwEHoUQDQgAE683eR4iT2DsCIyI9hgfK+62KU//1Burm41ZZgd8tPtPqQnPun10I
w10HCg4U3brwQVnuUREJiG5k5/Sn5AxBcQ==
-----END EC PRIVATE KEY-----
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#!/bin/bash

set -e
set -u

function create_user_and_database() {
local database=$1
echo " Creating user and database '$database'..."
psql -v ON_ERROR_STOP=1 --username "$POSTGRES_USER" <<-EOSQL
CREATE ROLE $database WITH LOGIN ENCRYPTED PASSWORD '$database' VALID UNTIL 'infinity';
CREATE DATABASE $database;
ALTER DATABASE $database OWNER TO $database;
EOSQL
}

if [ -n "$POSTGRES_ADDITIONAL_DATABASES" ]; then
echo "Additional database creation requested: $POSTGRES_ADDITIONAL_DATABASES"
for db in $(echo $POSTGRES_ADDITIONAL_DATABASES | tr ',' ' '); do
create_user_and_database $db
done
echo "Additional databases created."
fi
Loading
Loading