|
6 | 6 | # nix run .#dockerImage/submit-api
|
7 | 7 | # docker load -i result
|
8 | 8 | #
|
9 |
| -# cardano-submit-api |
10 |
| -# To launch with provided mainnet configuration |
| 9 | +# Scripts Mode: |
11 | 10 | #
|
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. |
13 | 13 | #
|
14 |
| -# To launch with provided testnet configuration |
| 14 | +# An example using a docker named volume to share ipc socket state: |
15 | 15 | #
|
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 |
17 | 20 | #
|
18 |
| -# Provide a complete command otherwise: |
| 21 | +# In "scripts" mode, the node.socket file is expected at /ipc. |
19 | 22 | #
|
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 |
22 | 23 | #
|
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. |
24 | 48 | #
|
25 | 49 | ############################################################################
|
26 |
| - |
27 | 50 | { pkgs
|
28 |
| -, commonLib |
29 | 51 | , dockerTools
|
30 | 52 |
|
31 | 53 | # The main contents of the image.
|
|
36 | 58 |
|
37 | 59 | # Other things to include in the image.
|
38 | 60 | , bashInteractive
|
39 |
| -, buildPackages |
40 | 61 | , cacert
|
41 | 62 | , coreutils
|
42 | 63 | , curl
|
|
75 | 96 | utillinux # System utilities for Linux
|
76 | 97 | ];
|
77 | 98 | };
|
78 |
| - # set up /tmp (override with TMPDIR variable) |
| 99 | + |
| 100 | + # Set up /tmp (override with TMPDIR variable) |
79 | 101 | extraCommands = ''
|
80 | 102 | mkdir -m 0777 tmp
|
81 | 103 | '';
|
82 | 104 | };
|
83 | 105 |
|
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>` |
86 | 109 | clusterStatements = lib.concatStringsSep "\n" (lib.mapAttrsToList (env: scripts: let
|
87 | 110 | scriptBin = scripts.${script};
|
88 | 111 | in ''
|
89 | 112 | elif [[ "$NETWORK" == "${env}" ]]; then
|
90 | 113 | exec ${scriptBin}/bin/${scriptBin.name} $@
|
91 | 114 | '') scripts);
|
92 | 115 |
|
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 | + ''; |
103 | 125 |
|
104 | 126 | in dockerTools.buildImage {
|
105 | 127 | name = "${repoName}";
|
106 |
| - fromImage = baseImage; |
107 | 128 | 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 | + ''; |
109 | 141 |
|
110 | 142 | copyToRoot = pkgs.buildEnv {
|
111 | 143 | name = "image-root";
|
|
119 | 151 | "${toString scripts.mainnet.${script}.passthru.service.port}/tcp" = {};
|
120 | 152 | };
|
121 | 153 | };
|
122 |
| - }; |
123 |
| - |
124 |
| -in nodeDockerImage |
| 154 | + } |
0 commit comments