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

Feature: Implement Stellar build and deployment files #25

Open
wants to merge 4 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
43 changes: 43 additions & 0 deletions stellar/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
FROM debian:stretch

EXPOSE 5432
EXPOSE 8000
EXPOSE 11625
EXPOSE 11626

RUN apt-get update \
&& apt-get install -y wget curl git libpq-dev libsqlite3-dev libsasl2-dev postgresql-client sudo vim zlib1g-dev jq netcat \
&& apt-get clean

ARG VERSION
COPY VERSION_HORIZON .
COPY checksum.sha256 .

# Links were taken from official image: https://github.com/stellar/docker-stellar-core-horizon/blob/master/install
# Stellar-core & Horizon

RUN wget -q https://s3.amazonaws.com/stellar.org/releases/stellar-core/stellar-core-${VERSION}_amd64.deb \
&& wget -q https://github.com/stellar/go/releases/download/horizon-v$(cat VERSION_HORIZON)/horizon-v$(cat VERSION_HORIZON)-linux-amd64.tar.gz \
&& sha256sum -c checksum.sha256 \
&& dpkg -i stellar-core-${VERSION}_amd64.deb \
&& rm stellar-core-${VERSION}_amd64.deb \
&& tar -zxvf horizon-v$(cat VERSION_HORIZON)-linux-amd64.tar.gz \
&& mv /horizon-v$(cat VERSION_HORIZON)-linux-amd64/horizon /usr/local/bin \
&& chmod +x /usr/local/bin/horizon \
&& rm -rf horizon-v$(cat VERSION_HORIZON)-linux-amd64.tar.gz /horizon-v$(cat VERSION_HORIZON)-linux-amd64

RUN ["mkdir", "-p", "/opt/stellar"]

RUN useradd --uid 10011001 --home-dir /home/stellar --no-log-init stellar \
&& mkdir -p /home/stellar \
&& chown -R stellar:stellar /home/stellar

RUN ["ln", "-s", "/opt/stellar", "/stellar"]
RUN ["ln", "-s", "/opt/stellar/core/etc/stellar-core.cfg", "/stellar-core.cfg"]
# RUN ["ln", "-s", "/opt/stellar/horizon/etc/horizon.env", "/horizon.env"]

ADD scripts/docker-entrypoint.sh /

ENTRYPOINT ["/docker-entrypoint.sh"]

CMD ["/usr/local/bin/stellar-core", "run", "--conf", "/stellar-core.cfg"]
11 changes: 11 additions & 0 deletions stellar/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# Stellar

## Start the cryptonode

```shell
docker-compose up -Vd *mainnet or testnet*`
```

## Usage

[Stellar Horizon API reference](https://developers.stellar.org/api/introduction/)
1 change: 1 addition & 0 deletions stellar/VERSION
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
13.2.0-1260-e45018ea
1 change: 1 addition & 0 deletions stellar/VERSION_HORIZON
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
1.5.0
2 changes: 2 additions & 0 deletions stellar/checksum.sha256
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
e37fca6f88c2aa26d7f14f770d09a68079cb8ae15aa004264f115b87815809a7 horizon-v1.5.0-linux-amd64.tar.gz
b5f9f9f6028aafdd1ab6863dbf6104822f4fe6643a42562dc203b0381b6b065b stellar-core-13.2.0-1260-e45018ea_amd64.deb
73 changes: 73 additions & 0 deletions stellar/config/stellar-core-pubnet.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
# This is an example config for setting up a validator.
# see https://www.stellar.org/developers/stellar-core/software/admin.html
# for how to properly configure your environment

# run `stellar-core gen-seed` to generate a public key and secret seed.
# Let us know the public key so we can add you to the validator list.
# set NODE_SEED below to the secret seed generated above.

# uncomment those two lines if you are running a validator node
# NODE_SEED="S123456ABCDE"
# NODE_IS_VALIDATOR=true

DATABASE="postgresql://dbname=stellar user=stellar password=changeme host=stellar-pg-pubnet"

#FAILURE_SAFETY is minimum number of nodes that are allowed to fail before you no longer have quorum
FAILURE_SAFETY=1

# number of ledgers to synchronize (time in seconds divided by 5)
# NB: full validators should run with CATCHUP_COMPLETE=true instead
CATCHUP_RECENT=60480

NETWORK_PASSPHRASE="Public Global Stellar Network ; September 2015"

# Populate NODE_NAMES, KNOW_PEERS, QUORUM and HISTORY sections with information
# on other validators
# for example https://github.com/stellar/docs/blob/master/validators.md
# or from https://dashboard.stellar.org/
NODE_NAMES=[
"GDIQKLQVOCD5UD6MUI5D5PTPVX7WTP5TAPP5OBMOLENBBD5KG434KYQ2 stronghold1",
"GAOO3LWBC4XF6VWRP5ESJ6IBHAISVJMSBTALHOQM2EZG7Q477UWA6L7U eno",
"GCJCSMSPIWKKPR7WEPIQG63PDF7JGGEENRC33OKVBSPUDIRL6ZZ5M7OO tempo.eu.com",
"GC5SXLNAM3C4NMGK2PXK4R34B5GNZ47FYQ24ZIBFDFOCU6D4KBN4POAE satoshipay",
"GD7FVHL2KUTUYNOJFRUUDJPDRO2MAZJ5KP6EBCU6LKXHYGZDUFBNHXQI umbrel",
"GCGB2S2KGYARPVIA37HYZXVRM2YZUEXA6S33ZU5BUDC6THSB62LZSTYH sdf_watcher1",
"GCM6QMP3DLRPTAZW2UZPCPX2LF3SXWXKPMP3GKFZBDSF3QZGV2G5QSTK sdf_watcher2",
"GABMKJM6I25XI4K7U6XWMULOUQIQ27BCTMLS6BYYSOWKTBUXVRJSXHYQ sdf_watcher3",
]

KNOWN_PEERS=[
"core-live-a.stellar.org:11625",
"core-live-b.stellar.org:11625",
"core-live-c.stellar.org:11625",
"validator1.stellar.stronghold.co",
"stellar.256kw.com",
"stellar1.tempo.eu.com",
"stellar.satoshipay.io"
]

# full validators (with history archive)
[QUORUM_SET]
VALIDATORS=[
"$sdf_watcher1", "$sdf_watcher2", "$sdf_watcher3"
]

# other validators that you want to include
# for best result, use a number of validators
# that can be expressed as 3f+1 (4, 7, 10 ,...)
[QUORUM_SET.basic]
VALIDATORS=[
"$stronghold1", "$eno", "$tempo.eu.com", "$satoshipay"
]

# History archives

# Stellar.org history store
[HISTORY.sdf1]
get="curl -sf http://history.stellar.org/prd/core-live/core_live_001/{0} -o {1}"

[HISTORY.sdf2]
get="curl -sf http://history.stellar.org/prd/core-live/core_live_002/{0} -o {1}"

[HISTORY.sdf3]
get="curl -sf http://history.stellar.org/prd/core-live/core_live_003/{0} -o {1}"
38 changes: 38 additions & 0 deletions stellar/config/stellar-core-testnet.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
HTTP_PORT=11626
PUBLIC_HTTP_PORT=true
LOG_FILE_PATH=""

NETWORK_PASSPHRASE="Test SDF Network ; September 2015"
KNOWN_CURSORS=["HORIZON"]
DATABASE="postgresql://dbname=stellar user=stellar password=changeme host=stellar-pg-testnet"
UNSAFE_QUORUM=true
FAILURE_SAFETY=1
CATCHUP_RECENT=100

[HISTORY.cache]
get="cp /opt/stellar/history-cache/{0} {1}"

[[HOME_DOMAINS]]
HOME_DOMAIN="testnet.stellar.org"
QUALITY="HIGH"

[[VALIDATORS]]
NAME="sdf_testnet_1"
HOME_DOMAIN="testnet.stellar.org"
PUBLIC_KEY="GDKXE2OZMJIPOSLNA6N6F2BVCI3O777I2OOC4BV7VOYUEHYX7RTRYA7Y"
ADDRESS="core-testnet1.stellar.org"
HISTORY="curl -sf http://history.stellar.org/prd/core-testnet/core_testnet_001/{0} -o {1}"

[[VALIDATORS]]
NAME="sdf_testnet_2"
HOME_DOMAIN="testnet.stellar.org"
PUBLIC_KEY="GCUCJTIYXSOXKBSNFGNFWW5MUQ54HKRPGJUTQFJ5RQXZXNOLNXYDHRAP"
ADDRESS="core-testnet2.stellar.org"
HISTORY="curl -sf http://history.stellar.org/prd/core-testnet/core_testnet_002/{0} -o {1}"

[[VALIDATORS]]
NAME="sdf_testnet_3"
HOME_DOMAIN="testnet.stellar.org"
PUBLIC_KEY="GC2V2EFSXN6SQTWVYA5EPJPBWWIMSD2XQNKUOHGEKB535AQE2I6IXV2Z"
ADDRESS="core-testnet3.stellar.org"
HISTORY="curl -sf http://history.stellar.org/prd/core-testnet/core_testnet_003/{0} -o {1}"
52 changes: 52 additions & 0 deletions stellar/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
version: '3.6'

services:
stellar-pg-testnet:
image: postgres:9
restart: on-failure
volumes:
- pg_data_testnet:/var/lib/postgresql/data
environment:
- POSTGRES_DB=stellar
- POSTGRES_USER=stellar
- POSTGRES_PASSWORD=changeme

stellar-node-testnet:
image: quay.io/openware/stellar:13.2.0-1260-e45018ea
restart: always
volumes:
- ./config/stellar-core-testnet.cfg:/stellar-core.cfg
- ./data/testnet:/data
environment:
INITIALIZE_DB: "true"
INITIALIZE_HISTORY_ARCHIVES: "true"
# ports:
# - 127.0.0.1:11625:11625
# - 127.0.0.1:11626:11626

stellar-pg-pubnet:
image: postgres:9
restart: on-failure
volumes:
- pg_data_pubnet:/var/lib/postgresql/data
environment:
- POSTGRES_DB=stellar
- POSTGRES_USER=stellar
- POSTGRES_PASSWORD=changeme

stellar-node-pubnet:
image: quay.io/openware/stellar:13.2.0-1260-e45018ea
restart: always
volumes:
- ./config/stellar-core-pubnet.cfg:/stellar-core.cfg
- ./data/pubnet:/data
environment:
INITIALIZE_DB: "true"
INITIALIZE_HISTORY_ARCHIVES: "true"
# ports:
# - 127.0.0.1:11625:11625
# - 127.0.0.1:11626:11626

volumes:
pg_data_testnet:
pg_data_pubnet:
54 changes: 54 additions & 0 deletions stellar/scripts/docker-entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
#!/usr/bin/env bash

set -ue

function stellar_core_init_db() {
if [ -z ${INITIALIZE_DB:-} ] || [ "${INITIALIZE_DB}" != "true" ]; then
echo "Not initializing DB (set INITIALIZE_DB=true if you want to initialize it)."
return 0
fi

local DB_INITIALIZED="/data/.db-initialized"

if [ -f $DB_INITIALIZED ]; then
echo "Core db has already been initialized."
return 0
fi

echo "Initializing core db..."

stellar-core new-db --conf /stellar-core.cfg

echo "Finished initializing core db"

touch $DB_INITIALIZED
}

function stellar_core_init_history_archives() {
if [ -z ${INITIALIZE_HISTORY_ARCHIVES:-} ] || [ "${INITIALIZE_HISTORY_ARCHIVES}" != "true" ]; then
echo "Not initializing history archives (set INITIALIZE_HISTORY_ARCHIVES=true if you want to initialize them)."
return 0
fi

for HISTORY_ARCHIVE in $(echo $HISTORY | jq -r 'to_entries[] | select (.value.put?) | .key'); do
local HISTORY_ARCHIVE_INITIALIZED="/data/.history-archive-${HISTORY_ARCHIVE}-initialized"

if [ -f $HISTORY_ARCHIVE_INITIALIZED ]; then
echo "History archive ${HISTORY_ARCHIVE} has already been initialized."
continue
fi

echo "Initializing history archive ${HISTORY_ARCHIVE}..."

stellar-core new-hist $HISTORY_ARCHIVE --conf /stellar-core.cfg

echo "Finished initializing history archive ${HISTORY_ARCHIVE}."

touch $HISTORY_ARCHIVE_INITIALIZED
done
}

stellar_core_init_db
stellar_core_init_history_archives

exec "$@"