Skip to content

Commit

Permalink
[ADP-3388] Add configs to docker image (#4685)
Browse files Browse the repository at this point in the history
- [x] Include the node configs in the docker image
- [x] Use the included configs in docker compose

ADP-3388
  • Loading branch information
paolino authored Jul 17, 2024
2 parents 4cbeaa7 + 1234eb3 commit 9f29038
Show file tree
Hide file tree
Showing 6 changed files with 50 additions and 29 deletions.
10 changes: 7 additions & 3 deletions .buildkite/pipeline.yml
Original file line number Diff line number Diff line change
Expand Up @@ -573,6 +573,7 @@ steps:
system: x86_64-linux
env:
SUCCESS_STATUS: syncing
USE_LOCAL_IMAGE: true

- label: Private Network Full Sync
timeout: 20
Expand All @@ -583,7 +584,8 @@ steps:
./run.sh sync
agents:
system: x86_64-linux

env:
USE_LOCAL_IMAGE: true

- label: Sanchonet Full Sync
timeout_in_minutes: 240
Expand All @@ -594,7 +596,8 @@ steps:
./run.sh sync
agents:
system: x86_64-linux

env:
USE_LOCAL_IMAGE: true

- label: Preprod Full Sync
timeout_in_minutes: 240
Expand All @@ -607,7 +610,8 @@ steps:
./run.sh sync
agents:
system: x86_64-linux

env:
USE_LOCAL_IMAGE: true

- group: Links
key: links-validity
Expand Down
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,8 @@ Accepeted variables for the start command are:
- `WALLET_DB` (default `./databases/wallet-db`): the directory where the wallet database will be stored
- `NODE_DB` (default `./databases/node-db`): the directory where the node database will be stored
- `NODE_SOCKET_DIR` (default `./.`): the directory where the node socket will be created
- `NODE_CONFIGS` (default `./configs`): the directory where the node configuration files will be retrieved from
- `NODE_CONFIGS`: the directory where the node configuration files will be retrieved from. In the absence of this variable, the node will use the configurations in the image.
You have to reflect the directory structure of the node configuration files in the image to use the docker-compose.yml file.
- `WALLET_TAG` (default 2024.7.7): the tag of the wallet image to use, can be `release-candidate`

For example, to start a wallet on `private` network:
Expand Down
48 changes: 33 additions & 15 deletions nix/docker.nix
Original file line number Diff line number Diff line change
Expand Up @@ -10,20 +10,20 @@

{ lib, stdenv
, runtimeShell, writeScriptBin, writeTextFile, dockerTools
, buildEnv

# The main contents of the image: cardano-wallet executables
, exes
# Executables to include in the image as a base layer: node and utilities
, base ? []
# Other things to include in the image.
, iana-etc, cacert, bashInteractive, coreutils
, iana-etc, cacert, bashInteractive, coreutils, gnugrep, findutils
, glibcLocales ? null

# Used to generate the docker image names
, repoName ? "cardanofoundation/cardano-wallet"
}:


let
version = (lib.head exes).version;

Expand Down Expand Up @@ -56,37 +56,55 @@ let
destination = "/etc/nsswitch.conf";
};

# System environment layer, which isn't going to change much between
# versions.
# Image containing a system environment.
# This image will not change much between versions.
envImage = dockerTools.buildImage {
name = "${repoName}-env";
contents = [
iana-etc cacert nsswitch-conf
bashInteractive coreutils
] ++ lib.optional haveGlibcLocales glibcLocales;

copyToRoot = buildEnv {
name = "${repoName}-env-packages";
paths = [
iana-etc cacert nsswitch-conf
bashInteractive coreutils gnugrep findutils
] ++ lib.optional haveGlibcLocales glibcLocales;
};
# set up /tmp (override with TMPDIR variable)
extraCommands = "mkdir -m 0777 tmp";
};

# Layer containing cardano-node backend and Adrestia toolbelt.
# Configuration files for cardano-node
nodeConfigs = lib.fileset.toSource {
root = ../.;
fileset = ../configs/cardano;
};

# Image containing basic Cardano tools, including cardano-node
baseImage = dockerTools.buildImage {
name = "${repoName}-base";
contents = base;
fromImage = envImage;
copyToRoot = buildEnv {
name = "${repoName}-base-packages";
paths = base ++ [ nodeConfigs ];
};
};

in
dockerTools.buildImage {
# Image containing the software of interest,
# here cardano-wallet.
mainImage = dockerTools.buildImage {
name = repoName;
tag = version;
fromImage = baseImage;
contents = exes ++ [ startScript ];
copyToRoot = buildEnv {
name = "${repoName}-main-packages";
paths = exes ++ [ startScript ];
};
config = {
EntryPoint = [ "start-cardano-wallet" ];
ExposedPorts = {
"${defaultPort}/tcp" = {}; # wallet api
};
Volume = [ dataDir ];
};
} // { inherit version; }
};
in
mainImage
// { inherit version; }
8 changes: 3 additions & 5 deletions run/common/docker/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ services:
volumes:
- ${NODE_DB}:/data
- ${NODE_SOCKET_DIR}:/ipc
- ${NODE_CONFIGS}:/configs
restart: on-failure
user: ${USER_ID}:${GROUP_ID}
logging:
Expand All @@ -18,18 +17,17 @@ services:
max-size: "50m"
entrypoint: []
command: >
cardano-node run --topology /configs/topology.json
cardano-node run --topology /configs/cardano/${NETWORK}/topology.json
--database-path /data
--socket-path /ipc/node.socket
--config /configs/config.json
--config /configs/cardano/${NETWORK}/config.json
+RTS -N -A16m -qg -qb -RTS
cardano-wallet:
image: cardanofoundation/cardano-wallet:${WALLET_TAG}
volumes:
- ${WALLET_DB}:/wallet-db
- ${NODE_SOCKET_DIR}:/ipc
- ${NODE_CONFIGS}:/configs
ports:
- ${WALLET_PORT}:8090
entrypoint: []
Expand All @@ -38,7 +36,7 @@ services:
--node-socket /ipc/${NODE_SOCKET_NAME}
--database /wallet-db
--listen-address 0.0.0.0
--testnet /configs/byron-genesis.json
--testnet /configs/cardano/${NETWORK}/byron-genesis.json
user: ${USER_ID}:${GROUP_ID}
restart: on-failure
Expand Down
4 changes: 3 additions & 1 deletion run/common/docker/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,9 @@ export NODE_CONFIGS

startup() {
# Pull the latest images
docker compose pull -q || true
if [ -z "${USE_LOCAL_IMAGE}" ]; then
docker compose pull -q
fi
# Start the service in detached mode
docker compose up -d
}
Expand Down
6 changes: 2 additions & 4 deletions run/mainnet/docker/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ services:
volumes:
- ${NODE_DB}:/data
- ${NODE_SOCKET_DIR}:/ipc
- ${NODE_CONFIGS}:/configs
restart: on-failure
user: ${USER_ID}:${GROUP_ID}
logging:
Expand All @@ -18,18 +17,17 @@ services:
max-size: "50m"
entrypoint: []
command: >
cardano-node run --topology /configs/topology.json
cardano-node run --topology /configs/cardano/mainnet/topology.json
--database-path /data
--socket-path /ipc/node.socket
--config /configs/config.json
--config /configs/cardano/mainnet/config.json
+RTS -N -A16m -qg -qb -RTS
cardano-wallet:
image: cardanofoundation/cardano-wallet:${WALLET_TAG}
volumes:
- ${WALLET_DB}:/wallet-db
- ${NODE_SOCKET_DIR}:/ipc
- ${NODE_CONFIGS}:/configs
entrypoint: []
command: >
cardano-wallet serve
Expand Down

0 comments on commit 9f29038

Please sign in to comment.