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.
- Loading branch information
1 parent
30c509f
commit efb7015
Showing
6 changed files
with
278 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
version: "3.4" | ||
x-logging: &logging | ||
logging: | ||
driver: json-file | ||
options: | ||
max-size: 10m | ||
max-file: "3" | ||
tag: '{{.ImageName}}|{{.Name}}|{{.ImageFullID}}|{{.FullID}}' | ||
|
||
services: | ||
consensus: | ||
restart: "${RESTART}" | ||
build: | ||
context: ./grandine | ||
dockerfile: Dockerfile.binary | ||
args: | ||
- BUILD_TARGET=${GRANDINE_SRC_BUILD_TARGET} | ||
- DOCKER_TAG=${GRANDINE_DOCKER_TAG} | ||
image: grandine:local | ||
user: grandine | ||
stop_grace_period: 1m | ||
volumes: | ||
- grandine-data:/var/lib/grandine | ||
- /etc/localtime:/etc/localtime:ro | ||
ports: | ||
- ${CC_P2P_PORT:-9000}:${CC_P2P_PORT:-9000}/tcp | ||
- ${CC_P2P_PORT:-9000}:${CC_P2P_PORT:-9000}/udp | ||
expose: | ||
- 9001/tcp | ||
networks: | ||
default: | ||
aliases: | ||
- eth2 | ||
<<: *logging | ||
entrypoint: | ||
- grandine | ||
- --data-dir | ||
- /var/lib/grandine | ||
- --http-address | ||
- 0.0.0.0 | ||
- --http-port | ||
- "9001" | ||
- --network | ||
- ${NETWORK} | ||
- --libp2p-port | ||
- ${CC_P2P_PORT:-9000} | ||
- --eth1-rpc-urls | ||
- ${EC_NODE} | ||
- --metrics | ||
- --graffiti | ||
- ${GRAFFITI} | ||
- --keystore-dir | ||
- /var/lib/grandine/validator-keys | ||
- --keystore-password-file | ||
- /var/lib/grandine/validator-passwords | ||
validator-import: | ||
restart: "no" | ||
image: grandine:local | ||
user: root | ||
volumes: | ||
- grandine-data:/var/lib/grandine | ||
- ${DEPCLI_LOCALDIR}/validator_keys:/validator_keys | ||
- /etc/localtime:/etc/localtime:ro | ||
environment: | ||
- KEYSTORE_PASSWORD=${KEYSTORE_PASSWORD:-''} | ||
entrypoint: /usr/local/bin/validator-import.sh | ||
eth: | ||
image: tianon/true | ||
restart: "no" | ||
depends_on: | ||
- consensus | ||
volumes: | ||
grandine-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,57 @@ | ||
version: "3.4" | ||
x-logging: &logging | ||
logging: | ||
driver: json-file | ||
options: | ||
max-size: 10m | ||
max-file: "3" | ||
tag: '{{.ImageName}}|{{.Name}}|{{.ImageFullID}}|{{.FullID}}' | ||
|
||
services: | ||
consensus: | ||
restart: "${RESTART}" | ||
build: | ||
context: ./grandine | ||
dockerfile: Dockerfile.binary | ||
args: | ||
- BUILD_TARGET=${GRANDINE_SRC_BUILD_TARGET} | ||
- DOCKER_TAG=${GRANDINE_DOCKER_TAG} | ||
image: grandine:local | ||
user: grandine | ||
stop_grace_period: 1m | ||
volumes: | ||
- grandineconsensus-data:/var/lib/grandine | ||
- /etc/localtime:/etc/localtime:ro | ||
ports: | ||
- ${CC_P2P_PORT:-9000}:${CC_P2P_PORT:-9000}/tcp | ||
- ${CC_P2P_PORT:-9000}:${CC_P2P_PORT:-9000}/udp | ||
expose: | ||
- 9001/tcp | ||
networks: | ||
default: | ||
aliases: | ||
- eth2 | ||
<<: *logging | ||
entrypoint: | ||
- grandine | ||
- --data-dir | ||
- /var/lib/grandine | ||
- --http-address | ||
- 0.0.0.0 | ||
- --http-port | ||
- "9001" | ||
- --network | ||
- ${NETWORK} | ||
- --libp2p-port | ||
- ${CC_P2P_PORT:-9000} | ||
- --eth1-rpc-urls | ||
- ${EC_NODE} | ||
- --metrics | ||
- --subscribe-all-subnets | ||
eth: | ||
image: tianon/true | ||
restart: "no" | ||
depends_on: | ||
- consensus | ||
volumes: | ||
grandineconsensus-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,39 @@ | ||
ARG DOCKER_TAG | ||
|
||
FROM sifrai/grandine:${DOCKER_TAG} | ||
|
||
# Unused, this is here to avoid build time complaints | ||
ARG BUILD_TARGET | ||
|
||
ARG USER=grandine | ||
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}" | ||
|
||
# Create data mount point with permissions | ||
RUN mkdir -p /var/lib/grandine/validator-keys && mkdir -p /var/lib/grandine/validator-passwords && chown ${USER}:${USER} -R /var/lib/grandine && chmod 700 -R /var/lib/grandine | ||
|
||
RUN set -eux; \ | ||
apt-get update; \ | ||
DEBIAN_FRONTEND=noninteractive TZ=Etc/UTC apt-get install -y gosu ca-certificates tzdata; \ | ||
rm -rf /var/lib/apt/lists/*; \ | ||
# verify that the binary works | ||
gosu nobody true | ||
|
||
# Scripts that handle permissions | ||
COPY ./validator-import.sh /usr/local/bin/ | ||
|
||
# For voluntary exit | ||
ENV KEYSTORE=nonesuch | ||
|
||
USER grandine | ||
|
||
ENTRYPOINT ["grandine"] |
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,97 @@ | ||
#!/bin/bash | ||
set -Eeuo pipefail | ||
|
||
# Copy keys, then restart script without root | ||
if [ "$(id -u)" = '0' ]; then | ||
cp /validator_keys/*.json /var/lib/grandine/validator-keys/ | ||
chown grandine:grandine /var/lib/grandine/validator-keys/* | ||
chmod 600 /var/lib/grandine/validator-keys/* | ||
echo "Copied validator key(s) from .eth/validator_keys" | ||
echo | ||
exec gosu grandine "$BASH_SOURCE" "$@" | ||
fi | ||
|
||
__non_interactive=0 | ||
if echo "$@" | grep -q '.*--non-interactive.*' 2>/dev/null ; then | ||
__non_interactive=1 | ||
fi | ||
for arg do | ||
shift | ||
[ "$arg" = "--non-interactive" ] && continue | ||
set -- "$@" "$arg" | ||
done | ||
|
||
if [ ${__non_interactive} = 1 ]; then | ||
for file in /var/lib/grandine/validator-keys/*.json ; do | ||
filename=$(basename $file .json) | ||
echo "$KEYSTORE_PASSWORD" > "/var/lib/grandine/validator-passwords/$filename.txt" | ||
done | ||
exit 0 | ||
fi | ||
|
||
# Only reached in interactive mode | ||
|
||
# Prompt for password. There's no check that the password is right. | ||
|
||
echo "Storing the validator key password(s) in plain text will allow the validator to start automatically without user input." | ||
echo | ||
while true; do | ||
read -rp "Do you wish to store the validator key password(s) inside this container? (y/n) " yn | ||
case $yn in | ||
[Yy]* ) break;; | ||
[Nn]* ) echo "Not storing plaintext validator key password(s)."; echo; echo "Please adjust grandine-base.yml and see instructions in README.md on how to start the client"; exit;; | ||
* ) echo "Please answer yes or no.";; | ||
esac | ||
done | ||
echo | ||
while true; do | ||
read -rp "Do all validator keys have the same password? (y/n) " yn | ||
case $yn in | ||
[Yy]* ) justone=1; break;; | ||
[Nn]* ) justone=0; break;; | ||
* ) echo "Please answer yes or no.";; | ||
esac | ||
done | ||
echo | ||
if [ $justone -eq 1 ]; then | ||
while true; do | ||
read -srp "Please enter the password for your validator key(s): " password1 | ||
echo | ||
read -srp "Please re-enter the password: " password2 | ||
echo | ||
if [ "$password1" == "$password2" ]; then | ||
break | ||
else | ||
echo "The two entered passwords do not match, please try again." | ||
echo | ||
fi | ||
done | ||
for file in /var/lib/grandine/validator-keys/*.json ; do | ||
filename=$(basename $file .json) | ||
echo "$password1" > "/var/lib/grandine/validator-passwords/$filename.txt" | ||
done | ||
else | ||
for file in /var/lib/grandine/validator-keys/*.json ; do | ||
filename=$(basename $file .json) | ||
while true; do | ||
read -srp "Please enter the password for your validator key stored in $filename: " password1 | ||
echo | ||
read -srp "Please re-enter the password: " password2 | ||
echo | ||
if [ "$password1" == "$password2" ]; then | ||
break | ||
else | ||
echo "The two entered passwords do not match, please try again." | ||
echo | ||
fi | ||
done | ||
echo "$password1" > "/var/lib/grandine/validator-passwords/$filename.txt" | ||
done | ||
fi | ||
|
||
chmod 600 /var/lib/grandine/validator-passwords/* | ||
|
||
echo | ||
echo "Validator key password(s) have been stored." | ||
echo "Please note: This tool currently does not verify that the validator key password(s) are correct. If password(s) don't match, just run this routine again." | ||
echo |