forked from eth-educators/eth-docker
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request eth-educators#266 from yorickdowne/main
Initial support for Lodestar consensus client
- Loading branch information
Showing
10 changed files
with
271 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,145 @@ | ||
version: "3.4" | ||
services: | ||
consensus: | ||
restart: "${RESTART}" | ||
build: | ||
context: ./lodestar | ||
dockerfile: ${LS_DOCKERFILE} | ||
args: | ||
- BUILD_TARGET=${LS_SRC_BUILD_TARGET} | ||
- DOCKER_TAG=${LS_DOCKER_TAG} | ||
image: lodestar:local | ||
user: lsconsensus | ||
stop_grace_period: 1m | ||
volumes: | ||
- lsconsensus-data:/var/lib/lodestar/consensus | ||
- /etc/timezone:/etc/timezone:ro | ||
- /etc/localtime:/etc/localtime:ro | ||
ports: | ||
- ${LS_PORT}:${LS_PORT}/tcp | ||
- ${LS_PORT}:${LS_PORT}/udp | ||
expose: | ||
- 9596/tcp | ||
entrypoint: | ||
- node | ||
- --max-old-space-size=8192 | ||
- /usr/app/packages/cli/bin/lodestar | ||
- beacon | ||
- --rootDir | ||
- /var/lib/lodestar/consensus | ||
- --api.rest.enabled | ||
- "true" | ||
- --api.rest.host | ||
- 0.0.0.0 | ||
- --network.discv5.bindAddr | ||
- "/ip4/0.0.0.0/udp/${LS_PORT}" | ||
- --network.localMultiaddrs | ||
- "/ip4/0.0.0.0/tcp/${LS_PORT}" | ||
- --eth1.providerUrl | ||
- ${EC_NODE} | ||
- --logLevel | ||
- ${LOG_LEVEL} | ||
- --network | ||
- ${NETWORK} | ||
validator: | ||
restart: "${RESTART}" | ||
build: | ||
context: ./lodestar | ||
dockerfile: ${LS_DOCKERFILE} | ||
args: | ||
- BUILD_TARGET=${LS_SRC_BUILD_TARGET} | ||
- DOCKER_TAG=${LS_DOCKER_TAG} | ||
image: lodestar:local | ||
user: lsvalidator | ||
volumes: | ||
- lsvalidator-data:/var/lib/lodestar/validators | ||
- /etc/timezone:/etc/timezone:ro | ||
- /etc/localtime:/etc/localtime:ro | ||
entrypoint: | ||
- node | ||
- --max-old-space-size=8192 | ||
- /usr/app/packages/cli/bin/lodestar | ||
- validator | ||
- --rootDir | ||
- /var/lib/lodestar/validators | ||
- --server | ||
- http://consensus:9596 | ||
- --graffiti | ||
- ${GRAFFITI} | ||
- --logLevel | ||
- ${LOG_LEVEL} | ||
- --network | ||
- ${NETWORK} | ||
validator-import: | ||
restart: "${RESTART}" | ||
image: lodestar:local | ||
user: root | ||
volumes: | ||
- lsvalidator-data:/var/lib/lodestar/validators | ||
- ${DEPCLI_LOCALDIR}/validator_keys:/validator_keys | ||
- /etc/timezone:/etc/timezone:ro | ||
- /etc/localtime:/etc/localtime:ro | ||
entrypoint: | ||
- validator-import.sh | ||
- node | ||
- --max-old-space-size=8192 | ||
- /usr/app/packages/cli/bin/lodestar | ||
- account | ||
- validator | ||
- import | ||
- --rootDir | ||
- /var/lib/lodestar/validators | ||
- --directory | ||
- /val_keys | ||
- --network | ||
- ${NETWORK} | ||
validator-exit: | ||
restart: "no" | ||
image: lodestar:local | ||
user: lsvalidator | ||
volumes: | ||
- lsvalidator-data:/var/lib/lodestar/validators | ||
- /etc/timezone:/etc/timezone:ro | ||
- /etc/localtime:/etc/localtime:ro | ||
entrypoint: | ||
- node | ||
- --max-old-space-size=8192 | ||
- /usr/app/packages/cli/bin/lodestar | ||
- account | ||
- validator | ||
- voluntary-exit | ||
- --rootDir | ||
- /var/lib/lodestar/validators | ||
- --server | ||
- http://consensus:9596 | ||
- --logLevel | ||
- ${LOG_LEVEL} | ||
- --network | ||
- ${NETWORK} | ||
validator-account: | ||
restart: "no" | ||
image: lodestar:local | ||
user: lsvalidator | ||
volumes: | ||
- lsvalidator-data:/var/lib/lodestar/validators | ||
- /etc/timezone:/etc/timezone:ro | ||
- /etc/localtime:/etc/localtime:ro | ||
entrypoint: | ||
- node | ||
- --max-old-space-size=8192 | ||
- /usr/app/packages/cli/bin/lodestar | ||
- account | ||
- validator | ||
- --rootDir | ||
- /var/lib/lodestar/validators | ||
- --network | ||
- ${NETWORK} | ||
eth: | ||
image: tianon/true | ||
restart: "no" | ||
depends_on: | ||
- consensus | ||
- validator | ||
volumes: | ||
lsconsensus-data: | ||
lsvalidator-data: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
ARG DOCKER_TAG | ||
|
||
FROM chainsafe/lodestar:${DOCKER_TAG} | ||
|
||
# Here only to avoid build-time errors | ||
ARG BUILD_TARGET | ||
|
||
RUN apk update && apk add --no-cache ca-certificates tzdata bash su-exec && rm -rf /var/cache/apk/* | ||
|
||
# Scripts that handle permissions | ||
COPY ./validator-import.sh /usr/local/bin/ | ||
|
||
ARG USER=lsconsensus | ||
ARG UID=10002 | ||
|
||
# See https://stackoverflow.com/a/55757473/12429735RUN | ||
RUN adduser \ | ||
--disabled-password \ | ||
--gecos "" \ | ||
--home "/nonexistent" \ | ||
--shell "/sbin/nologin" \ | ||
--no-create-home \ | ||
--uid "${UID}" \ | ||
"${USER}" | ||
|
||
RUN mkdir -p /var/lib/lodestar/consensus && chown ${USER}:${USER} /var/lib/lodestar/consensus && chmod 700 /var/lib/lodestar/consensus | ||
|
||
ARG USER=lsvalidator | ||
ARG UID=10000 | ||
|
||
# See https://stackoverflow.com/a/55757473/12429735RUN | ||
RUN adduser \ | ||
--disabled-password \ | ||
--gecos "" \ | ||
--home "/nonexistent" \ | ||
--shell "/sbin/nologin" \ | ||
--no-create-home \ | ||
--uid "${UID}" \ | ||
"${USER}" | ||
|
||
# Create data mount point with permissions | ||
RUN mkdir -p /var/lib/lodestar/validators && chown ${USER}:${USER} /var/lib/lodestar/validators && chmod 700 /var/lib/lodestar/validators | ||
|
||
ENTRYPOINT ["node", "--max-old-space-size=8192", "/usr/app/packages/cli/bin/lodestar"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
FROM node:16-alpine as build | ||
|
||
# Here only to avoid build-time errors | ||
ARG DOCKER_TAG | ||
|
||
ARG BUILD_TARGET | ||
|
||
RUN apk update && apk add --no-cache git g++ make python3 bash && rm -rf /var/cache/apk/* | ||
RUN ln -s /usr/bin/python3 /usr/bin/python | ||
|
||
WORKDIR /usr/app | ||
|
||
RUN bash -c "git clone https://github.com/ChainSafe/lodestar.git && cd lodestar && git config advice.detachedHead false && git fetch --all --tags && git checkout ${BUILD_TARGET} && yarn install --non-interactive --frozen-lockfile && node ./scripts/getGitData /usr/app/lodestar/.git-data.json && rm -r .git" | ||
|
||
FROM node:16-alpine | ||
|
||
RUN apk update && apk add --no-cache ca-certificates tzdata bash su-exec && rm -rf /var/cache/apk/* | ||
|
||
WORKDIR /usr/app | ||
COPY --from=build /usr/app/lodestar . | ||
ENV DOCKER_LODESTAR_GIT_DATA_FILEPATH /usr/app/.git-data.json | ||
|
||
# Scripts that handle permissions | ||
COPY ./validator-import.sh /usr/local/bin/ | ||
|
||
ARG USER=lsconsensus | ||
ARG UID=10002 | ||
|
||
# See https://stackoverflow.com/a/55757473/12429735RUN | ||
RUN adduser \ | ||
--disabled-password \ | ||
--gecos "" \ | ||
--home "/nonexistent" \ | ||
--shell "/sbin/nologin" \ | ||
--no-create-home \ | ||
--uid "${UID}" \ | ||
"${USER}" | ||
|
||
RUN mkdir -p /var/lib/lodestar/consensus && chown ${USER}:${USER} /var/lib/lodestar/consensus && chmod 700 /var/lib/lodestar/consensus | ||
|
||
ARG USER=lsvalidator | ||
ARG UID=10000 | ||
|
||
# See https://stackoverflow.com/a/55757473/12429735RUN | ||
RUN adduser \ | ||
--disabled-password \ | ||
--gecos "" \ | ||
--home "/nonexistent" \ | ||
--shell "/sbin/nologin" \ | ||
--no-create-home \ | ||
--uid "${UID}" \ | ||
"${USER}" | ||
|
||
# Create data mount point with permissions | ||
RUN mkdir -p /var/lib/lodestar/validators && chown ${USER}:${USER} /var/lib/lodestar/validators && chmod 700 /var/lib/lodestar/validators | ||
|
||
ENTRYPOINT ["node", "--max-old-space-size=8192", "/usr/app/packages/cli/bin/lodestar"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
#!/bin/bash | ||
set -Eeuo pipefail | ||
|
||
# Copy keys, then restart script without root | ||
if [ "$(id -u)" = '0' ]; then | ||
mkdir /val_keys | ||
cp /validator_keys/* /val_keys/ | ||
chown lsvalidator:lsvalidator /val_keys/* | ||
exec su-exec lsvalidator "$BASH_SOURCE" "$@" | ||
fi | ||
|
||
exec "$@" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters