Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(ln): initial version of lightning-regtest modules #92

Draft
wants to merge 50 commits into
base: devel
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
50 commits
Select commit Hold shift + click to select a range
58fb626
feat(ln): initial version of ln-common-client modules
theborakompanioni Jul 19, 2023
118ded4
feat(ln): initial version of lightning-regtest modules
theborakompanioni Jul 24, 2023
788ce02
feat(example): add run configuration for lightning-regtest example app
theborakompanioni Jul 27, 2023
a77ea49
chore(ln): prevent postgres vacuum warnings in lightning regtest env
theborakompanioni Jul 27, 2023
92d817a
chore: remove unused class ShutdownHooks
theborakompanioni Jul 27, 2023
2792b83
refactor: rename module ln-common-client to lightning-commons
theborakompanioni Jul 27, 2023
f4f2a22
regtest(ln): speed up gossip and block sync for cln nodes
theborakompanioni Jul 28, 2023
1e71fac
regtest(ln): individual bitcoin rpcauth for regtest lightning nodes
theborakompanioni Jul 28, 2023
be8304f
cleanup: remove unused static var in RouteVerification
theborakompanioni Aug 1, 2023
44da5f9
chore(ln): add baseClient method to LnCommonClient
theborakompanioni Aug 1, 2023
5e06cb8
refactor: outsource node info caching to inner class NodeInfos
theborakompanioni Aug 1, 2023
ab9d8c9
chore(ln): add 'connect' to LnCommonClient
theborakompanioni Aug 3, 2023
2a58dc8
chore(ln): prefix messages of LightningCommonClient with Common*
theborakompanioni Aug 3, 2023
6598d6c
chore(ln): add 'newAddress' to LightningCommonClient
theborakompanioni Aug 3, 2023
4bf872d
chore(ln): add 'createInvoice' to LightningCommonClient
theborakompanioni Aug 3, 2023
511a976
chore(ln): add 'listPeers' to LightningCommonClient
theborakompanioni Aug 3, 2023
9d8117a
chore(ln): add 'openChannel' to LightningCommonClient
theborakompanioni Aug 3, 2023
4d152af
fix(test): fix setup of lightning-regtest-example-app integration tests
theborakompanioni Aug 3, 2023
2fc7d17
chore(ln): add 'listUnspent' to LightningCommonClient
theborakompanioni Aug 3, 2023
99431d2
chore(ln): add 'listPeerChannels' to LightningCommonClient
theborakompanioni Aug 3, 2023
7779abd
chore(ln): add remote balance to PeerChannel message
theborakompanioni Aug 4, 2023
542f349
fix(ln): fix num pending channels in common clients
theborakompanioni Aug 4, 2023
1022b3a
chore(ln): add 'pay' to LightningCommonClient
theborakompanioni Aug 4, 2023
8021b94
chore(ln): add 'lookupInvoice' to LightningCommonClient
theborakompanioni Aug 4, 2023
3daecce
chore(ln): add 'lookupPayment' to LightningCommonClient
theborakompanioni Aug 4, 2023
e65abb3
chore(test): cleanup lightning regtest devel test
theborakompanioni Aug 6, 2023
87ad318
chore(ln): add lnd node to lightning devel setup
theborakompanioni Aug 29, 2023
c8b125e
chore(ln): configure hostname and p2p port of nodes
theborakompanioni Aug 29, 2023
bad2020
chore(ln): use faucet instead of block rewards to fund node wallets
theborakompanioni Aug 29, 2023
386845a
fix(ln): catch error if peer is already connected
theborakompanioni Aug 30, 2023
5bb0f4c
chore(ln): support route verification with common client
theborakompanioni Sep 5, 2023
0766a78
refactor: remove generics from LightningCommonClient
theborakompanioni Sep 13, 2023
02e2370
build(deps): cln from v23.05.2 to v23.08 in regtest-setup-devel
theborakompanioni Sep 13, 2023
200c95d
build(deps): update cln testcontainer from v23.05 to v23.08
theborakompanioni Sep 13, 2023
381cd84
chore(ln): add healthcheck for postgres container in docker-compose
theborakompanioni Sep 18, 2023
58df653
chore(ln): add healthcheck for bitcoind container in docker-compose
theborakompanioni Sep 18, 2023
a1a5122
chore(ln): add healthcheck for lnd container in docker-compose
theborakompanioni Sep 19, 2023
eb63b3f
chore(ln): add healthcheck for cln container in docker-compose
theborakompanioni Sep 19, 2023
1d50145
chore: do not publish new lightning modules for now
theborakompanioni Sep 19, 2023
6af9de6
build(deps): update lnd to v0.17.0-beta in regtest-setup-devel
theborakompanioni Oct 9, 2023
6714843
build(deps): update postgres to v16.0-alpine3.18 in regtest-setup-devel
theborakompanioni Oct 9, 2023
499433e
dev(regtest): update lnd instance from v0.17.0-beta to v0.17.2-beta
theborakompanioni Dec 2, 2023
45ab422
chore(ln): add sync warning to ln common client getinfo response
theborakompanioni Dec 2, 2023
a141401
chore(ln): prevent lnd from syning indefinitely by mining a single bl…
theborakompanioni Dec 2, 2023
890de45
fix: remove brackets in example application name
theborakompanioni Jan 11, 2024
5b45aa2
dev(regtest): update lnd instance from v0.17.2-beta to v0.17.4-beta
theborakompanioni Mar 8, 2024
23151b5
dev(regtest): update lnd instance from v0.17.4-beta to v0.18.2-beta
theborakompanioni Oct 6, 2024
468d90e
dev(regtest): (partially) update cln to v24.08.1
theborakompanioni Oct 10, 2024
096a2ea
dev(regtest): disallow deprecated apis (cln)
theborakompanioni Oct 10, 2024
c4c56a6
dev(regtest): disable dns (cln)
theborakompanioni Oct 10, 2024
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
7 changes: 5 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -372,10 +372,13 @@ configure(subprojects.findAll { project -> project.subprojects.isEmpty() &&
apply from: "${project.rootDir}/proto.gradle"
}

// enable publishing for all subproject except for "example applications"
// enable publishing for all subprojects except for some not intended to be or not ready yet
// (e.g. "example applications" or modules still in beta)
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"
}

Expand Down
3 changes: 3 additions & 0 deletions changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,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