Skip to content

Commit 6c7b98d

Browse files
authored
Merge pull request #81 from blinklabs-io/chore/backport-changes
chore: backport changes from main
2 parents 3063233 + b65142c commit 6c7b98d

File tree

9 files changed

+295
-78
lines changed

9 files changed

+295
-78
lines changed

CODEOWNERS

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# Blink Labs
2+
#
3+
* @agaffney @verbotenj @wolf31o2

CODE_OF_CONDUCT.md

Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
# Contributor Covenant Code of Conduct
2+
3+
## Our Pledge
4+
5+
We as members, contributors, and leaders pledge to make participation in our community a harassment-free experience for everyone, regardless of age, body size, visible or invisible disability, ethnicity, sex characteristics, gender identity and expression, level of experience, education, socio-economic status, nationality, personal appearance, race, religion, or sexual identity and orientation.
6+
7+
We pledge to act and interact in ways that contribute to an open, welcoming, diverse, inclusive, and healthy community.
8+
9+
## Our Standards
10+
11+
Examples of behavior that contributes to a positive environment for our community include:
12+
13+
* Demonstrating empathy and kindness toward other people
14+
* Being respectful of differing opinions, viewpoints, and experiences
15+
* Giving and gracefully accepting constructive feedback
16+
* Accepting responsibility and apologizing to those affected by our mistakes, and learning from the experience
17+
* Focusing on what is best not just for us as individuals, but for the overall community
18+
19+
Examples of unacceptable behavior include:
20+
21+
* The use of sexualized language or imagery, and sexual attention or advances of any kind
22+
* Trolling, insulting or derogatory comments, and personal or political attacks
23+
* Public or private harassment
24+
* Publishing others' private information, such as a physical or email address, without their explicit permission
25+
* Contacting individual members, contributors, or leaders privately, outside designated community mechanisms, without their explicit permission
26+
* Other conduct which could reasonably be considered inappropriate in a professional setting
27+
28+
## Enforcement Responsibilities
29+
30+
Community leaders are responsible for clarifying and enforcing our standards of acceptable behavior and will take appropriate and fair corrective action in response to any behavior that they deem inappropriate, threatening, offensive, or harmful.
31+
32+
Community leaders have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, and will communicate reasons for moderation decisions when appropriate.
33+
34+
## Scope
35+
36+
This Code of Conduct applies within all community spaces, and also applies when an individual is officially representing the community in public spaces. Examples of representing our community include using an official e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event.
37+
38+
## Enforcement
39+
40+
Instances of abusive, harassing, or otherwise unacceptable behavior may be reported to the community leaders responsible for enforcement at [email protected]. All complaints will be reviewed and investigated promptly and fairly.
41+
42+
All community leaders are obligated to respect the privacy and security of the reporter of any incident.
43+
44+
## Enforcement Guidelines
45+
46+
Community leaders will follow these Community Impact Guidelines in determining the consequences for any action they deem in violation of this Code of Conduct:
47+
48+
### 1. Correction
49+
50+
**Community Impact**: Use of inappropriate language or other behavior deemed unprofessional or unwelcome in the community.
51+
52+
**Consequence**: A private, written warning from community leaders, providing clarity around the nature of the violation and an explanation of why the behavior was inappropriate. A public apology may be requested.
53+
54+
### 2. Warning
55+
56+
**Community Impact**: A violation through a single incident or series of actions.
57+
58+
**Consequence**: A warning with consequences for continued behavior. No interaction with the people involved, including unsolicited interaction with those enforcing the Code of Conduct, for a specified period of time. This includes avoiding interactions in community spaces as well as external channels like social media. Violating these terms may lead to a temporary or permanent ban.
59+
60+
### 3. Temporary Ban
61+
62+
**Community Impact**: A serious violation of community standards, including sustained inappropriate behavior.
63+
64+
**Consequence**: A temporary ban from any sort of interaction or public communication with the community for a specified period of time. No public or private interaction with the people involved, including unsolicited interaction with those enforcing the Code of Conduct, is allowed during this period. Violating these terms may lead to a permanent ban.
65+
66+
### 4. Permanent Ban
67+
68+
**Community Impact**: Demonstrating a pattern of violation of community standards, including sustained inappropriate behavior, harassment of an individual, or aggression toward or disparagement of classes of individuals.
69+
70+
**Consequence**: A permanent ban from any sort of public interaction within the community.
71+
72+
## Attribution
73+
74+
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 2.0, available at <https://www.contributor-covenant.org/version/2/0/code_of_conduct.html>.
75+
76+
Community Impact Guidelines were inspired by [Mozilla's code of conduct enforcement ladder](https://github.com/mozilla/diversity).
77+
78+
[homepage]: https://www.contributor-covenant.org
79+
80+
For answers to common questions about this code of conduct, see the FAQ at <https://www.contributor-covenant.org/faq>. Translations are available at <https://www.contributor-covenant.org/translations>.

Dockerfile

Lines changed: 12 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM ghcr.io/blinklabs-io/haskell:8.10.7-3.6.2.0 as cardano-node-build
1+
FROM ghcr.io/blinklabs-io/haskell:8.10.7-3.6.2.0-4 as cardano-node-build
22
# Install cardano-node
33
ARG NODE_VERSION=1.35.7
44
ENV NODE_VERSION=${NODE_VERSION}
@@ -23,12 +23,15 @@ RUN echo "Building tags/${NODE_VERSION}..." \
2323
&& rm -rf /code/cardano-node/dist-newstyle/ \
2424
&& rm -rf /root/.cabal/store/ghc-${GHC_VERSION}
2525

26-
FROM debian:stable-slim as cardano-node
26+
FROM debian:bookworm-slim as cardano-node
2727
ENV LD_LIBRARY_PATH="/usr/local/lib:$LD_LIBRARY_PATH"
2828
ENV PKG_CONFIG_PATH="/usr/local/lib/pkgconfig:$PKG_CONFIG_PATH"
2929
COPY --from=cardano-node-build /usr/local/lib/ /usr/local/lib/
3030
COPY --from=cardano-node-build /usr/local/include/ /usr/local/include/
3131
COPY --from=cardano-node-build /root/.local/bin/cardano-* /usr/local/bin/
32+
COPY --from=ghcr.io/blinklabs-io/mithril-client:0.4.2-1 /bin/mithril-client /usr/local/bin/
33+
COPY --from=ghcr.io/blinklabs-io/nview:0.6.1 /bin/nview /usr/local/bin/
34+
COPY --from=ghcr.io/blinklabs-io/txtop:0.2.0 /bin/txtop /usr/local/bin/
3235
COPY bin/ /usr/local/bin/
3336
COPY config/ /opt/cardano/config/
3437
RUN apt-get update -y && \
@@ -37,32 +40,22 @@ RUN apt-get update -y && \
3740
curl \
3841
iproute2 \
3942
jq \
40-
libffi7 \
43+
libffi8 \
4144
libgmp10 \
4245
liblmdb0 \
4346
libncursesw5 \
4447
libnuma1 \
4548
libsystemd0 \
46-
libssl1.1 \
49+
libssl3 \
4750
libtinfo6 \
48-
llvm-11-runtime \
51+
llvm-14-runtime \
52+
netbase \
4953
pkg-config \
5054
procps \
55+
sqlite3 \
56+
wget \
5157
zlib1g && \
52-
rm -rf /var/lib/apt/lists/*
53-
RUN curl -sLo /usr/local/bin/gLiveView.sh \
54-
https://raw.githubusercontent.com/cardano-community/guild-operators/master/scripts/cnode-helper-scripts/gLiveView.sh && \
55-
curl -sL \
56-
https://raw.githubusercontent.com/cardano-community/guild-operators/master/scripts/cnode-helper-scripts/env | \
57-
sed \
58-
-e "s|#CNODE_HOME=.*|CNODE_HOME=/opt/cardano |" \
59-
-e "s|#CNODE_PORT=.*|CNODE_PORT=\${CARDANO_PORT:-3001} |" \
60-
-e "s|#CONFIG=.*|CONFIG=\${CARDANO_CONFIG:-/opt/cardano/config/\${CARDANO_NETWORK:-mainnet}-config.json} |" \
61-
-e "s|#SOCKET=.*|SOCKET=\${CARDANO_SOCKET_PATH:-/opt/cardano/ipc/socket} |" \
62-
-e "s|#TOPOLOGY=.*|TOPOLOGY=\${CARDANO_TOPOLOGY:-/opt/cardano/config/\${CARDANO_NETWORK:-mainnet}-topology.json} |" \
63-
-e "s|#LOG_DIR=.*|LOG_DIR=\${CARDANO_LOG_DIR:-/opt/cardano/logs} |" \
64-
-e "s|#DB_DIR=.*|DB_DIR=\${CARDANO_DATABASE_PATH:-/opt/cardano/data} |" > \
65-
/usr/local/bin/env && \
58+
rm -rf /var/lib/apt/lists/* && \
6659
chmod +x /usr/local/bin/*
6760
EXPOSE 3001 12788 12798
6861
ENTRYPOINT ["/usr/local/bin/entrypoint"]

LICENSE

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

33
Copyright (c) 2022 CloudStruct, LLC.
4-
Copyright (c) 2023 Blink Labs, Inc.
4+
Copyright (c) 2023 Blink Labs Software
55

66
Permission is hereby granted, free of charge, to any person obtaining a copy
77
of this software and associated documentation files (the "Software"), to deal

README.md

Lines changed: 130 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,85 @@ invoked. There is a `NETWORK` environment variable which can be used as a
1818
short cut to starting nodes on a specific named Cardano network with a default
1919
configuration.
2020

21-
### Using run (Recommended for SPO)
21+
We recommend using this method for running the container if you are not
22+
familiar with running a node.
23+
24+
For nodes on the `preprod` and `mainnet` networks, the container will start
25+
fetching the latest Mithril snapshot if an empty data directory is detected.
26+
This snapshot will be used to bootstrap the node into an operating state much
27+
more rapidly than doing a sync from the beginning of the chain. This behavior
28+
can be disabled in the advanced path below.
29+
30+
### Using NETWORK (Recommended)
31+
32+
Using the `NETWORK` environment variable causes the entrypoint script to use
33+
the simplified path. The only configurable option in this path is the
34+
`NETWORK` environment variable itself.
35+
36+
This is in keeping with the IOHK image behavior.
37+
38+
To run a Cardano full node on preprod:
39+
40+
```bash
41+
docker run --detach \
42+
--name cardano-node \
43+
-v node-data:/data/db \
44+
-v node-ipc:/ipc \
45+
-e NETWORK=preprod \
46+
-p 3001:3001 \
47+
ghcr.io/blinklabs-io/cardano-node
48+
```
49+
50+
Node logs can be followed:
51+
52+
```bash
53+
docker logs -f cardano-node
54+
```
55+
56+
The node can be monitoring using [nview](https://github.com/blinklabs-io/nview)
57+
from within the container. We run `nview` from within the same container as
58+
our running node to get access to information about the node process.
59+
60+
```bash
61+
docker exec -ti cardano-node nview
62+
```
63+
64+
#### Running the Cardano CLI
65+
66+
To run a Cardano CLI command, we use the `node-ipc` volume from our node.
67+
68+
```bash
69+
docker run --rm -ti \
70+
-e NETWORK=preprod \
71+
-v node-ipc:/ipc \
72+
ghcr.io/blinklabs-io/cardano-node cli <command>
73+
```
74+
75+
This can be added to a shell alias:
76+
77+
```bash
78+
alias cardano-cli="docker run --rm -ti \
79+
-e NETWORK=preprod \
80+
-v node-ipc:/ipc \
81+
ghcr.io/blinklabs-io/cardano-node cli"
82+
```
83+
84+
Now, you can use cardano-cli commands as you would, normally.
85+
86+
```bash
87+
cardano-cli query tip --network-magic 1
88+
```
89+
90+
Or, for a node running with NETWORK=mainnet:
91+
92+
```bash
93+
cardano-cli query tip --mainnet
94+
```
95+
96+
### Using run (Recommended for SPO/Advanced)
2297

2398
Using the `run` argument to the image causes the entrypoint script to use the
24-
fully configurable code path.
99+
fully configurable code path. Do not set the `NETWORK` environment variable.
25100

26101
To run a Cardano full node on mainnet with minimal configuration and defaults:
27102

@@ -34,23 +109,59 @@ docker run --detach \
34109
ghcr.io/blinklabs-io/cardano-node run
35110
```
36111

112+
**NOTE** The container paths for persist disks are different in this mode
113+
37114
The above maps port 3001 on the host to 3001 on the container, suitable
38115
for use as a mainnet relay node. We use docker volumes for our persistent data
39116
storage and IPC (interprocess communication) so they live beyond the lifetime
40-
of the container.
117+
of the container. To mount local host paths instead of using Docker's built in
118+
volumes, use the local path on the left side of a `-v` argument.
119+
120+
An example of a more advanced configuration for mainnet:
121+
122+
```bash
123+
docker run --detach \
124+
--name cardano-node \
125+
--restart unless-stopped \
126+
-e CARDANO_CONFIG=/opt/cardano/config/mainnet-p2p-config.json \
127+
-e CARDANO_TOPOLOGY=/opt/cardano/config/mainnet-p2p-topology.json \
128+
-v /srv/cardano/node-db:/opt/cardano/data \
129+
-v /srv/cardano/node-ipc:/opt/cardano/ipc \
130+
-p 3001:3001 \
131+
-p 12798:12798 \
132+
ghcr.io/blinklabs-io/cardano-node run
133+
```
134+
135+
The above uses Docker's built in supervisor to restart a container which fails
136+
for any reason. This will also cause the container to automatically restart
137+
after a host reboot, so long as Docker is configured to start on boot. The
138+
current default configuration for mainnet does not enable P2P, so we override
139+
the configuration with the shipped `p2p-config.json` and its accompanying
140+
`p2p-topology.json` to enable it. Our node's persistent data and client
141+
communication socket are mapped to `/src/cardano/node-db` and
142+
`/src/cardano/node-ipc` on the host, respectively. This allows for running
143+
applications directly on the host which may need access to these. Last, we add
144+
mapping the host's port 12798 to the container 12798, which is the port for
145+
exposing the node's metrics in Prometheus format, for monitoring.
146+
147+
This mode of operation allows configuring multiple facets of the node using
148+
environment variables, described below.
41149

42150
Node logs can be followed:
43151

44152
```bash
45-
docker logs -f cardano-node
153+
docker logs -f -n 500 cardano-node
46154
```
47155

156+
Adding the `-n 500` to the logs command limits the logs to the last 500 lines
157+
before following.
158+
48159
#### Configuration using environment variables
49160

50161
The power in using `run` is being able to configure the node's behavior to
51162
provide the correct type of service.
52163

53-
This behavior can be changes via the following environment variables:
164+
This behavior can be changed via the following environment variables:
54165

55166
- `CARDANO_CONFIG_BASE`
56167
- A directory which contains configuration files (default:
@@ -99,29 +210,23 @@ and operational certificate.
99210
- Stake pool identity certificate (default:
100211
`${CARDANO_CONFIG_BASE}/keys/node.cert`
101212

102-
### Using NETWORK (standalone)
213+
#### Controlling Mithril snapshots
103214

104-
Using the `NETWORK` environment variable causes the entrypoint script to use
105-
the simplified path. The only configurable option in this path is the
106-
`NETWORK` environment variable itself.
215+
If the container does not find a protocolMagicId file within the
216+
`CARDANO_DATABASE_PATH` location, it will initiate Mithril snapshot downloads
217+
for preprod and mainnet networks. This can be disabled by setting
218+
`RESTORE_SNAPSHOT` to `false`.
107219

108-
**NOTE** The container paths for persist disks is different in this mode
220+
- `AGGREGATOR_ENDPOINT`
221+
- Mithril Aggregator URL (default:
222+
`https://aggregator.release-${CARDANO_NETWORK}.api.mithril.network/aggregator`)
223+
- `GENESIS_VERIFICATION_KEY`
224+
- Network specific Genesis Verification Key (default:
225+
`reads file at: ${CARDANO_CONFIG_BASE}/${CARDANO_NETWORK}/genesis.vkey`)
226+
- `SNAPSHOT_DIGEST`
227+
- Digest identifier to fetch (default: `latest`)
109228

110-
This is in keeping with the IOHK image behavior.
111-
112-
To run a Cardano full node on preview:
113-
114-
```bash
115-
docker run --detach \
116-
--name cardano-node \
117-
-v node-data:/data/db \
118-
-v node-ipc:/ipc \
119-
-e NETWORK=preview \
120-
-p 3001:3001 \
121-
ghcr.io/blinklabs-io/cardano-node
122-
```
123-
124-
## Running the CLI
229+
#### Running the Cardano CLI
125230

126231
To run a Cardano CLI command, we use the `node-ipc` volume from our node.
127232

@@ -144,9 +249,3 @@ Now, you can use cardano-cli commands as you would, normally.
144249
```bash
145250
cardano-cli query tip --mainnet
146251
```
147-
148-
Or, for preview:
149-
150-
```bash
151-
cardano-cli query tip --network-magic 2
152-
```

0 commit comments

Comments
 (0)