Skip to content

Commit 9cbf03a

Browse files
committed
bitte: Pull ports from env.
(cherry picked from commit 6aea8c3)
1 parent 9559140 commit 9cbf03a

File tree

6 files changed

+23
-24
lines changed

6 files changed

+23
-24
lines changed

bitte/default.nix

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,23 +11,19 @@ in
1111
plutus-playground-server-entrypoint = pkgs.callPackage ./plutus-playground-server.nix {
1212
variant = "plutus";
1313
pkg = plutus-playground.server;
14-
port = 4003;
1514
};
1615
plutus-playground-client-entrypoint = playgroundStatic {
1716
client = plutus-playground.client;
1817
variant = "plutus";
19-
port = 8081;
2018
};
2119

2220
marlowe-playground-server-entrypoint = pkgs.callPackage ./plutus-playground-server.nix {
2321
variant = "marlowe";
2422
pkg = marlowe-playground.server;
25-
port = 4004;
2623
};
2724
marlowe-playground-client-entrypoint = playgroundStatic {
2825
client = marlowe-playground.client;
2926
variant = "marlowe";
30-
port = 8087;
3127
};
3228

3329
marlowe-run-entrypoint = pkgs.callPackage ./pab.nix {
@@ -37,6 +33,5 @@ in
3733

3834
marlowe-website-entrypoint = staticSite {
3935
root = marlowe-web;
40-
port = 8088;
4136
};
4237
}

bitte/pab.nix

Lines changed: 17 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,40 +1,37 @@
1-
{ writeShellScriptBin, writeText, pabExe, staticPkg, cacert, coreutils, lib }:
1+
{ writeShellScriptBin, writeText, pabExe, staticPkg, cacert, coreutils, lib, gnused }:
22
let
33
dbFile = "/var/lib/pab/pab-core.db";
44

5-
webserverPort = 9080;
6-
walletPort = 8086;
7-
nodePort = 8082;
8-
chainIndexPort = 8083;
9-
signingProcessPort = 8084;
5+
# /var/lib isn't right but whatever
6+
pabYaml = "/var/lib/pab/pab.yaml";
107

118
slotZeroTime = 1596059091000; # POSIX time of slot zeron is milliseconds. See note [Datetime to slot] in Marlowe.Slot
129
slotLengthMillis = 1000;
1310

1411
constantFee = 10; # Constant fee per transaction in lovelace
1512
scriptsFeeFactor = 0.0; # Factor by which to multiply the size-dependent scripts fee in lovelace
1613

17-
pabYaml = writeText "pab.yaml" (builtins.toJSON {
14+
pabYamlIn = writeText "pab.yaml.in" (builtins.toJSON {
1815
dbConfig = {
1916
dbConfigFile = dbFile;
2017
dbConfigPoolSize = 20;
2118
};
2219

2320
pabWebserverConfig = {
24-
baseUrl = "http://localhost:${builtins.toString webserverPort}";
21+
baseUrl = "http://localhost:@WEBSERVER_PORT@";
2522
staticDir = "${staticPkg}";
2623
permissiveCorsPolicy = false;
2724
};
2825

2926
walletServerConfig = {
30-
baseUrl = "http://localhost:${builtins.toString walletPort}";
27+
baseUrl = "http://localhost:@WALLET_PORT@";
3128
wallet = {
3229
getWallet = 1;
3330
};
3431
};
3532

3633
nodeServerConfig = {
37-
mscBaseUrl = "http://localhost:${builtins.toString nodePort}";
34+
mscBaseUrl = "http://localhost:@NODE_PORT@";
3835
mscSocketPath = "/tmp/node-server.sock";
3936
mscRandomTxInterval = 20000000;
4037
mscSlotConfig = {
@@ -58,7 +55,7 @@ let
5855
};
5956

6057
chainIndexConfig = {
61-
ciBaseUrl = "http://localhost:${builtins.toString chainIndexPort}";
58+
ciBaseUrl = "http://localhost:@CHAIN_INDEX_PORT@";
6259
ciWatchedAddresses = [ ];
6360
};
6461

@@ -67,7 +64,7 @@ let
6764
};
6865

6966
signingProcessConfig = {
70-
spBaseUrl = "http://localhost:${builtins.toString signingProcessPort}";
67+
spBaseUrl = "http://localhost:@SIGNING_PROCESS_PORT@";
7168
spWallet = {
7269
getWallet = "1";
7370
};
@@ -95,6 +92,14 @@ writeShellScriptBin "entrypoint" ''
9592
9693
export SYSTEM_CERTIFICATE_PATH=${cacert}/etc/ssl/certs/ca-bundle.crt
9794
95+
${gnused}/bin/sed -e "s|@WEBSERVER_PORT@|$((PORT_RANGE_BASE))|g" \
96+
-e "s|@NODE_PORT@|$((PORT_RANGE_BASE + 1))|g" \
97+
-e "s|@CHAIN_INDEX_PORT@|$((PORT_RANGE_BASE + 2))|g" \
98+
-e "s|@SIGNING_PROCESS_PORT@|$((PORT_RANGE_BASE + 3))|g" \
99+
-e "s|@WALLET_PORT@|$((PORT_RANGE_BASE + 4))|g" \
100+
${pabYamlIn} > ${pabYaml}
101+
102+
98103
${pab-init-cmd}/bin/pab-init-cmd
99104
100105
exec ${pabExe} --config=${pabYaml} all-servers

bitte/playground-static.nix

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,9 @@
22
let
33
shiftedDocs = linkFarm docs.name [{ name = "doc"; path = docs; }];
44
in
5-
{ variant, client, port }: staticSite {
5+
{ variant, client }: staticSite {
66
root = (symlinkJoin {
77
name = "${variant}-playground-client-and-docs";
88
paths = [ client shiftedDocs ];
99
});
10-
inherit port;
1110
}

bitte/plutus-playground-server.nix

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
{ writeShellScriptBin, pkg, variant, symlinkJoin, lib, cacert, port }:
1+
{ writeShellScriptBin, pkg, variant, symlinkJoin, lib, cacert }:
22

33
let
44
deps = [ pkg ];
55
entrypoint = writeShellScriptBin "entrypoint" ''
66
export PATH=${lib.makeBinPath deps}
77
export SYSTEM_CERTIFICATE_PATH=${cacert}/etc/ssl/certs/ca-bundle.crt
8-
${variant}-playground-server webserver -p ${toString port}
8+
${variant}-playground-server webserver -p $PORT
99
'';
1010
in
1111
symlinkJoin {

bitte/static-site.nix

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
{ writeShellScriptBin, symlinkJoin, lib, writeText, lighttpd }: { root, port }:
1+
{ writeShellScriptBin, symlinkJoin, lib, writeText, lighttpd }: { root }:
22

33
let
44
config = writeText "lighttpd.conf" ''
55
server.modules = ("mod_deflate")
66
server.document-root = "${root}"
7-
server.port = ${toString port}
7+
server.port = env.PORT
88
index-file.names = ("index.html")
99
mimetype.assign = (
1010
".css" => "text/css",

bitte/web-ghc-server.nix

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
let
44
entrypoint = writeShellScriptBin "entrypoint" ''
5-
${web-ghc-server}/bin/web-ghc-server webserver -p 8009 --bind 0.0.0.0
5+
${web-ghc-server}/bin/web-ghc-server webserver -p $PORT --bind 0.0.0.0
66
'';
77
in
88
symlinkJoin {

0 commit comments

Comments
 (0)