Skip to content

Commit aa51649

Browse files
committed
imp: align oci cardano-submit-api paths w/ node image, update docs
1 parent ca31652 commit aa51649

File tree

4 files changed

+74
-39
lines changed

4 files changed

+74
-39
lines changed

docker-compose.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ services:
1919
depends_on:
2020
- cardano-node
2121
volumes:
22-
- node-ipc:/node-ipc
22+
- node-ipc:/ipc
2323
ports:
2424
- 8090:8090
2525
restart: on-failure

nix/docker/default.nix

+12-7
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,12 @@
1212
# To launch cardano-node with pre-loaded configuration, "scripts" mode,
1313
# use the NETWORK env variable to declare an existing cardano network name.
1414
#
15-
# An example using a docker volume to persist state:
15+
# An example using a docker named volume to persist state:
1616
#
17-
# docker run -v data:/data -e NETWORK=mainnet ghcr.io/intersectmbo/cardano-node
17+
# docker run \
18+
# -v data:/data \
19+
# -e NETWORK=mainnet \
20+
# ghcr.io/intersectmbo/cardano-node
1821
#
1922
# In "scripts" mode, default state directories include /{data,ipc,logs}, with
2023
# /data/db being the default database state location.
@@ -128,14 +131,16 @@ let
128131
utillinux # System utilities for Linux
129132
];
130133
};
131-
# set up /tmp (override with TMPDIR variable)
134+
135+
# Set up /tmp (override with TMPDIR variable)
132136
extraCommands = ''
133137
mkdir -m 0777 tmp
134138
'';
135139
};
136140

137-
# Image with all iohk-nix network configs or utilizes a configuration volume mount
138-
# To choose a network, use `-e NETWORK testnet`
141+
# For "script" mode, generate scripts for iohk-nix networks which can be
142+
# utilized by setting the environment NETWORK variable to the desired
143+
# network in the docker command: `-e NETWORK <network>`
139144
clusterStatements = lib.concatStringsSep "\n" (lib.mapAttrsToList (env: scripts: let
140145
scriptBin = scripts.${script};
141146
in ''
@@ -154,7 +159,7 @@ let
154159
fi
155160
'';
156161

157-
# The Docker context with static content
162+
# The docker context with static content
158163
context = ./context;
159164

160165
genCfgs = let
@@ -192,7 +197,7 @@ in
192197
tag = "${gitrev}";
193198
fromImage = baseImage;
194199

195-
# Set creation date to build time. Breaks reproducibility
200+
# Set creation date to build time. Breaks reproducibility.
196201
created = "now";
197202

198203
extraCommands = ''

nix/docker/submit-api.nix

+60-30
Original file line numberDiff line numberDiff line change
@@ -6,26 +6,48 @@
66
# nix run .#dockerImage/submit-api
77
# docker load -i result
88
#
9-
# cardano-submit-api
10-
# To launch with provided mainnet configuration
9+
# Scripts Mode:
1110
#
12-
# docker run -e NETWORK=mainnet ghcr.io/intersectmbo/cardano-submit-api:<TAG>
11+
# To launch cardano-submit-api with pre-loaded configuration, "scripts" mode,
12+
# use the NETWORK env variable to declare an existing cardano network name.
1313
#
14-
# To launch with provided testnet configuration
14+
# An example using a docker named volume to share ipc socket state:
1515
#
16-
# docker run -e NETWORK=testnet ghcr.io/intersectmbo/cardano-submit-api:<TAG>
16+
# docker run \
17+
# -v node-ipc:/ipc \
18+
# -e NETWORK=mainnet \
19+
# ghcr.io/intersectmbo/cardano-submit-api
1720
#
18-
# Provide a complete command otherwise:
21+
# In "scripts" mode, the node.socket file is expected at /ipc.
1922
#
20-
# docker run -v $PWD/config.yaml:/config.yaml ghcr.io/intersectmbo/cardano-submit-api:<TAG> \
21-
# --config /config.yaml --mainnet --socket-path /node-ipc/node.socket
2223
#
23-
# See the docker-compose.yml for demonstration of using Docker secrets instead of mounting a pgpass
24+
# Custom Mode:
25+
#
26+
# To launch cardano-submit-api with a custom configuration, "custom" mode,
27+
# leave the NETWORK env variable unset and provide a complete set of
28+
# cardano-submit-api args to the entrypoint.
29+
#
30+
# For example:
31+
#
32+
# docker run \
33+
# -v $PWD/config.json:/config.json \
34+
# ghcr.io/intersectmbo/cardano-submit-api \
35+
# --config /config.json \
36+
# --mainnet \
37+
# --socket-path /ipc/node.socket
38+
#
39+
# See the docker-compose.yml for a demonstration of cardano-node and
40+
# cardano-submit-api together.
41+
#
42+
#
43+
# Bind Mounting Considerations:
44+
#
45+
# In the container a /node-ipc directory is symlinked to /ipc both align the
46+
# default ipc socket state directory in both the cardano-node and
47+
# cardano-submit-api images and remain backward compatible.
2448
#
2549
############################################################################
26-
2750
{ pkgs
28-
, commonLib
2951
, dockerTools
3052

3153
# The main contents of the image.
@@ -36,7 +58,6 @@
3658

3759
# Other things to include in the image.
3860
, bashInteractive
39-
, buildPackages
4061
, cacert
4162
, coreutils
4263
, curl
@@ -75,37 +96,48 @@ let
7596
utillinux # System utilities for Linux
7697
];
7798
};
78-
# set up /tmp (override with TMPDIR variable)
99+
100+
# Set up /tmp (override with TMPDIR variable)
79101
extraCommands = ''
80102
mkdir -m 0777 tmp
81103
'';
82104
};
83105

84-
# Image with all iohk-nix network configs or utilizes a configuration volume mount
85-
# To choose a network, use `-e NETWORK testnet`
106+
# For "script" mode, generate scripts for iohk-nix networks which can be
107+
# utilized by setting the environment NETWORK variable to the desired
108+
# network in the docker command: `-e NETWORK <network>`
86109
clusterStatements = lib.concatStringsSep "\n" (lib.mapAttrsToList (env: scripts: let
87110
scriptBin = scripts.${script};
88111
in ''
89112
elif [[ "$NETWORK" == "${env}" ]]; then
90113
exec ${scriptBin}/bin/${scriptBin.name} $@
91114
'') scripts);
92115

93-
nodeDockerImage = let
94-
entry-point = writeScriptBin "entry-point" ''
95-
#!${runtimeShell}
96-
if [[ -z "$NETWORK" ]]; then
97-
exec ${pkgs.${exe}}/bin/${exe} $@
98-
${clusterStatements}
99-
else
100-
echo "Managed configuration for network "$NETWORK" does not exist"
101-
fi
102-
'';
116+
entry-point = writeScriptBin "entry-point" ''
117+
#!${runtimeShell}
118+
if [[ -z "$NETWORK" ]]; then
119+
exec ${pkgs.${exe}}/bin/${exe} $@
120+
${clusterStatements}
121+
else
122+
echo "Managed configuration for network "$NETWORK" does not exist"
123+
fi
124+
'';
103125

104126
in dockerTools.buildImage {
105127
name = "${repoName}";
106-
fromImage = baseImage;
107128
tag = "${gitrev}";
108-
created = "now"; # Set creation date to build time. Breaks reproducibility
129+
fromImage = baseImage;
130+
131+
# Set creation date to build time. Breaks reproducibility.
132+
created = "now";
133+
134+
extraCommands = ''
135+
# The "scripts" operation mode of this image, when the NETWORK env var is
136+
# set to a valid network, will use the following default directories
137+
# mounted at /:
138+
mkdir -p ipc
139+
ln -sv ipc node-ipc
140+
'';
109141

110142
copyToRoot = pkgs.buildEnv {
111143
name = "image-root";
@@ -119,6 +151,4 @@ let
119151
"${toString scripts.mainnet.${script}.passthru.service.port}/tcp" = {};
120152
};
121153
};
122-
};
123-
124-
in nodeDockerImage
154+
}

nix/pkgs.nix

+1-1
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ in with final;
113113
submitApiDockerImage =
114114
let
115115
defaultConfig = {
116-
socketPath = "/node-ipc/node.socket";
116+
socketPath = "/ipc/node.socket";
117117
listenAddress = "0.0.0.0";
118118
};
119119
in

0 commit comments

Comments
 (0)