Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update for leap + certbot #3

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@ configs/nginx.conf
downloads
shared/nginx/*.conf
shared/nodeos/*.sock
certbot/*
9 changes: 5 additions & 4 deletions Dockerfile-minimal-api
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
FROM ubuntu:18.04

# install required software
RUN apt-get update --fix-missing && apt-get install -y curl git dnsutils net-tools
RUN apt-get update --fix-missing && apt-get install -y curl git dnsutils net-tools wget

# setup folder structure
RUN mkdir /eosio
Expand All @@ -15,12 +15,13 @@ ARG NODEOS_VERSION
ENV NODEOS_VERSION $NODEOS_VERSION

# build nodeos
RUN git clone $NODEOS_REPOSITORY /eosio/build
WORKDIR /eosio/build
RUN git checkout $NODEOS_VERSION
RUN git clone -b $NODEOS_VERSION $NODEOS_REPOSITORY /eosio/build
RUN git submodule update --init --recursive
RUN apt-get update --fix-missing && ./scripts/eosio_build.sh -y
RUN apt-get update --fix-missing
RUN ./scripts/install_deps.sh && ./scripts/pinned_build.sh /eosio/deps /eosio/build/build $(nproc)
RUN cp /eosio/build/build/programs/nodeos/nodeos /eosio/nodeos
RUN rm -rf /eosio/build/build /eosio/build/deps

# configure nodeos
COPY configs/config.ini /eosio/base.ini
Expand Down
Empty file modified Dockerfile-minimal-p2p
100644 → 100755
Empty file.
Empty file modified Dockerfile-minimal-sampler
100644 → 100755
Empty file.
19 changes: 15 additions & 4 deletions README.md
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -24,17 +24,28 @@ cp configs/docker/default.env .env
This file contains the following parameters:

```
# The name of the network this environment is for (must be unique on the host machine)
NETWORK_NAME=EOS

# The port to expose the nodeos api(s) on the host machine
NETWORK_PORT_API=8888

# The port to expose the nodeos p2p procotol on the host machine
NETWORK_PORT_P2P=9876

# The git repository of the nodeos (EOSIO) repository to use
NODEOS_REPOSITORY=https://github.com/EOSIO/eos.git
NODEOS_REPOSITORY=https://github.com/AntelopeIO/leap.git

# The branch/tag of nodeos to checkout during the build process
NODEOS_VERSION=v2.1.0
NODEOS_VERSION=v3.1.0

# A snapshot (compressed as tar.gz) to use during the startup of this node
NODEOS_SNAPSHOT=https://snapshots.greymass.network/jungle/latest.tar.gz
#NODEOS_SNAPSHOT=https://snapshots.greymass.network/jungle/latest.tar.gz
NODEOS_SNAPSHOT=https://snapshots.greymass.network/eos/latest.tar.gz

# Peers to inject into the nodeos configuration
NODEOS_PEERS=peer.jungle3.alohaeos.com:9876 jungle.eosn.io:9876 jungle3.eosrio.io:58012
#NODEOS_PEERS=peer.jungle3.alohaeos.com:9876 jungle.eosn.io:9876 jungle3.eosrio.io:58012
NODEOS_PEERS=seed.greymass.com:9876 p2p.mainnet.eosrio.io:9876 p2p.donates2eden.io:9876 p2p.eoscafeblock.com:9000 p2p.eosdetroit.io:3018 peer.main.alohaeos.com:9876 p2p.eos42.io:9876 eos.seed.eosnation.io:9876
```

The second thing you'll need to configure is the nodeos configuration file itself. Create a copy of this configuration file as outlined below, and it'll be passed to the container for use.
Expand Down
Empty file modified configs/docker/default.env
100644 → 100755
Empty file.
13 changes: 12 additions & 1 deletion configs/docker/nginx.yaml
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,17 @@ services:
ports:
- "${NETWORK_PORT_API}:8888"
- "${NETWORK_PORT_P2P}:9876"
- 80:80
- 443:443
restart: always
volumes:
- ../nginx.conf:/etc/nginx/nginx.conf:ro
- ../../shared:/eosio/shared
- ../../shared:/eosio/shared
- /opt/eosio/src/docker-nodeos/certbot/www/:/var/www/certbot/:rw
- /opt/eosio/src/docker-nodeos/certbot/conf/:/etc/nginx/ssl/:rw
- /opt/eosio/src/docker-nodeos/certbot/letsencrypt/:/etc/letsencrypt/:rw
logging:
options:
max-size: "10m"
max-file: "3"

Empty file modified configs/docker/nodeos-minimal-api.yaml
100644 → 100755
Empty file.
Empty file modified configs/docker/nodeos-minimal-base.yaml
100644 → 100755
Empty file.
Empty file modified configs/docker/nodeos-minimal-p2p.yaml
100644 → 100755
Empty file.
Empty file modified configs/docker/nodeos-minimal-sampler.yaml
100644 → 100755
Empty file.
2 changes: 1 addition & 1 deletion configs/nginx/nginx.conf
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ http {

upstream nodes {
include /eosio/shared/nginx/*.conf;
server nodeos:8888 weight=1;
server nodeos:8881 weight=1;
}

server {
Expand Down
4 changes: 2 additions & 2 deletions configs/nodeos/example-minimal-api.config.ini
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ http-validate-host = false
# state
read-mode = head
validation-mode = full
chain-state-db-size-mb = 131070
chain-state-db-size-mb = 16384
reversible-blocks-db-size-mb = 2048

# blocks - Retain 24 hours worth of blocks (2 * 60 * 60 * 24 = 172800)
Expand All @@ -27,4 +27,4 @@ max-retained-block-files = 1728

# plugins
plugin = eosio::chain_plugin eosio::chain_api_plugin
plugin = eosio::http_plugin
plugin = eosio::http_plugin
Empty file modified configs/nodeos/example-minimal-p2p.config.ini
100644 → 100755
Empty file.
Empty file modified docker-compose.override.yaml
100644 → 100755
Empty file.
11 changes: 9 additions & 2 deletions docker-compose.yaml
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,16 @@ services:
file: ./configs/docker/nodeos-minimal-api.yaml
service: nodeos
nginx:
depends_on:
- nodeos
# depends_on:
# - nodeos
extends:
file: ./configs/docker/nginx.yaml
service: nginx
profiles: ["nginx"]
certbot:
image: certbot/certbot:latest
volumes:
- ./certbot/www/:/var/www/certbot/:rw
- ./certbot/logs:/var/log/letsencrypt/:rw
- ./certbot/letsencrypt/:/etc/letsencrypt/:rw

80 changes: 80 additions & 0 deletions init-letsencrypt.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
#!/bin/bash

if ! [ -x "$(command -v docker-compose)" ]; then
echo 'Error: docker-compose is not installed.' >&2
exit 1
fi

domains=(api.eos.heliosrising.com)
rsa_key_size=4096
data_path="./certbot"
email="[email protected]" # Adding a valid address is strongly recommended
staging=0 # Set to 1 if you're testing your setup to avoid hitting request limits

if [ -d "$data_path" ]; then
read -p "Existing data found for $domains. Continue and replace existing certificate? (y/N) " decision
if [ "$decision" != "Y" ] && [ "$decision" != "y" ]; then
exit
fi
fi


if [ ! -e "$data_path/conf/options-ssl-nginx.conf" ] || [ ! -e "$data_path/conf/ssl-dhparams.pem" ]; then
echo "### Downloading recommended TLS parameters ..."
mkdir -p "$data_path/conf"
curl -s https://raw.githubusercontent.com/certbot/certbot/master/certbot-nginx/certbot_nginx/_internal/tls_configs/options-ssl-nginx.conf > "$data_path/conf/options-ssl-nginx.conf"
curl -s https://raw.githubusercontent.com/certbot/certbot/master/certbot/certbot/ssl-dhparams.pem > "$data_path/conf/ssl-dhparams.pem"
echo
fi

echo "### Creating dummy certificate for $domains ..."
path="/etc/letsencrypt/live/$domains"
mkdir -p "$data_path/conf/live/$domains"
docker-compose run --rm --entrypoint "\
openssl req -x509 -nodes -newkey rsa:$rsa_key_size -days 1\
-keyout '$path/privkey.pem' \
-out '$path/fullchain.pem' \
-subj '/CN=localhost'" certbot
echo


echo "### Starting nginx ..."
docker-compose up --force-recreate -d nginx
echo

echo "### Deleting dummy certificate for $domains ..."
docker-compose run --rm --entrypoint "\
rm -Rf /etc/letsencrypt/live/$domains && \
rm -Rf /etc/letsencrypt/archive/$domains && \
rm -Rf /etc/letsencrypt/renewal/$domains.conf" certbot
echo


echo "### Requesting Let's Encrypt certificate for $domains ..."
#Join $domains to -d args
domain_args=""
for domain in "${domains[@]}"; do
domain_args="$domain_args -d $domain"
done

# Select appropriate email arg
case "$email" in
"") email_arg="--register-unsafely-without-email" ;;
*) email_arg="--email $email" ;;
esac

# Enable staging mode if needed
if [ $staging != "0" ]; then staging_arg="--staging"; fi

docker-compose run --rm --entrypoint "\
certbot certonly --webroot -w /var/www/certbot \
$staging_arg \
$email_arg \
$domain_args \
--rsa-key-size $rsa_key_size \
--agree-tos \
--force-renewal" certbot
echo

echo "### Reloading nginx ..."
docker-compose exec nginx nginx -s reload
9 changes: 9 additions & 0 deletions peers.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
p2p-peer-address = eos.seed.eosnation.io:9876
p2p-peer-address = seed.greymass.com:9876
p2p-peer-address = p2p.mainnet.eosrio.io:9876
p2p-peer-address = p2p.donates2eden.io:9876
p2p-peer-address = p2p.eoscafeblock.com:9000
p2p-peer-address = p2p.eosdetroit.io:3018
p2p-peer-address = peer.main.alohaeos.com:9876
p2p-peer-address = p2p.eos42.io:9876
p2p-peer-address = eos.seed.eosnation.io:9876
7 changes: 4 additions & 3 deletions scripts/entrypoint-minimal-api.sh
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -21,18 +21,19 @@ IP=`ifconfig eth0 | grep 'inet ' | awk '{print $2}'`
INDEX=`dig -x $IP +short | sed 's/.*_\([0-9]*\)\..*/\1/'`
NODEOS_SOCK=/eosio/shared/nodeos/$NETWORK_NAME$INDEX.sock
echo "generating unique unix sock file name ($NODEOS_SOCK)"
echo unix-socket-path = $NODEOS_SOCK >> /eosio/sock.ini
rm /eosio/sock.ini
echo unix-socket-path = $NODEOS_SOCK > /eosio/sock.ini
touch $NODEOS_SOCK
chmod 777 $NODEOS_SOCK

# Create nginx upstream entry for this server
echo "server unix:$NODEOS_SOCK fail_timeout=1 max_fails=3 weight=65535;" > /eosio/shared/nginx/$NETWORK_NAME$INDEX.conf

# Combine all configs to final version
cat /eosio/peers.ini /eosio/sock.ini /eosio/base.ini >> /eosio/config.ini
cat /eosio/peers.ini /eosio/sock.ini /eosio/base.ini > /eosio/config.ini
echo "config.ini generation complete!"

# Start based on snapshot
echo "starting nodeos..."
cd /eosio
/eosio/nodeos --data-dir=/ramdisk --config-dir=. --snapshot=/eosio/downloads/snapshot.bin
/eosio/nodeos --data-dir=/ramdisk --config-dir=. --snapshot=/eosio/downloads/snapshot.bin
26 changes: 0 additions & 26 deletions scripts/entrypoint-minimal-p2p.sh

This file was deleted.

38 changes: 0 additions & 38 deletions scripts/entrypoint-minimal-sampler.sh

This file was deleted.

Empty file modified shared/nginx/.gitkeep
100644 → 100755
Empty file.
Empty file modified shared/nodeos/.gitkeep
100644 → 100755
Empty file.