-
Notifications
You must be signed in to change notification settings - Fork 1
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
0 parents
commit 1346d0c
Showing
11 changed files
with
213 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
data/ | ||
log/ |
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,8 @@ | ||
data/ | ||
log/ | ||
|
||
.vscode | ||
boto.cfg | ||
docker-compose.yml | ||
gcloud-service-account-key.json | ||
stellar-core.cfg |
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,47 @@ | ||
FROM debian:stretch-slim | ||
|
||
LABEL maintainer="Evil Martians <[email protected]>" | ||
|
||
ARG STELLAR_VERSION="9.2.0-9" | ||
|
||
# hack to make postgresql-client install work on slim | ||
RUN mkdir -p /usr/share/man/man1 \ | ||
&& mkdir -p /usr/share/man/man7 | ||
|
||
# prerequisites for stellar-core | ||
RUN apt-get update \ | ||
&& DEBIAN_FRONTEND=noninteractive apt-get -y dist-upgrade \ | ||
&& DEBIAN_FRONTEND=noninteractive apt-get -y install curl gnupg2 apt-transport-https man-db \ | ||
&& apt-get clean \ | ||
&& rm -rf /var/lib/apt/lists/* | ||
|
||
# Stellar core installation | ||
RUN curl -q https://apt.stellar.org/SDF.asc | apt-key add - \ | ||
&& echo "deb https://apt.stellar.org/public stable/" | tee -a /etc/apt/sources.list.d/SDF.list \ | ||
&& apt-get update \ | ||
&& DEBIAN_FRONTEND=noninteractive apt-get -y install stellar-core=$STELLAR_VERSION \ | ||
&& apt-get clean \ | ||
&& rm -rf /var/lib/apt/lists/* | ||
|
||
# Additional packages | ||
RUN apt-get update \ | ||
&& DEBIAN_FRONTEND=noninteractive apt-get -y install postgresql-client s3cmd python-pip \ | ||
&& pip install "pyasn1>=0.4.3" \ | ||
&& pip install gsutil \ | ||
&& apt-get clean \ | ||
&& rm -rf /var/lib/apt/lists/* | ||
|
||
|
||
ADD init_db.sh /usr/local/bin/stellar_init_db.sh | ||
ADD init_cache.sh /usr/local/bin/stellar_init_cache.sh | ||
ADD entrypoint.sh /entrypoint.sh | ||
ADD wait_for_postgres.sh /usr/local/bin/wait_for_postgres.sh | ||
|
||
# USER stellar | ||
|
||
EXPOSE 11625 | ||
EXPOSE 11626 | ||
|
||
WORKDIR /var/lib/stellar | ||
|
||
ENTRYPOINT [ "/entrypoint.sh" ] |
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,13 @@ | ||
# Stellar Core Docker Image | ||
|
||
This repository is used to build a [Docker image](https://quay.io/repository/evilmartians/docker-stellar-core?tab=info) containing Stellar Core package with some tools to bootstrap Stellar Core installation and manage remote history uploading. | ||
|
||
Currently, only `gsutil` and Google Cloud Storage are supported as a remote backend. s3cmd & AWS S3 implementation is planned for the future release. There is an option to store history locally for test purposes. | ||
|
||
This image does not support a multiple Stellar Core history backend yet. It's a big downside, sorry. | ||
|
||
There is **no** `confd` or other template or configuration engines included as it is intended to be used in a Helm Chart which has its own templating capabilities. | ||
|
||
## Example | ||
|
||
See included `docker-compose-example.yml` for clues how to hack it. |
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,5 @@ | ||
[Credentials] | ||
gs_service_key_file = /etc/mobius-service-account.json | ||
|
||
[GSUtil] | ||
default_project_id = YOURPROJECTID |
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,31 @@ | ||
version: "3" | ||
services: | ||
postgres: | ||
image: postgres:9.6-alpine | ||
ports: | ||
- "5432" | ||
networks: | ||
- stellar | ||
environment: | ||
- POSTGRES_PASSWORD=password | ||
stellar-core: | ||
image: stellar-core:latest | ||
command: | ||
- "--conf /etc/stellar/stellar-core.cfg" | ||
environment: | ||
- STELLAR_CORE_DATABASE_URL=postgresql://dbname=stellarcore host=postgres user=postgres password=password | ||
- STELLAR_CORE_HISTORY_CACHE_TYPE=gcloud | ||
- STELLAR_CORE_HISTORY_CACHE_PATH=gs://YOURBUCKETNAME/ | ||
networks: | ||
- stellar | ||
volumes: | ||
- ./stellar-core-testnet-example.cfg:/etc/stellar/stellar-core.cfg | ||
- ./boto-example.cfg:/etc/boto.cfg | ||
- ./gcloud-service-account-key.json:/etc/mobius-service-account.json | ||
- ./data:/var/lib/stellar/ | ||
- ./logs:/var/log/stellar | ||
depends_on: | ||
- postgres | ||
|
||
networks: | ||
stellar: |
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,9 @@ | ||
#!/bin/bash | ||
|
||
set -ue | ||
|
||
/usr/local/bin/wait_for_postgres.sh | ||
/usr/local/bin/stellar_init_db.sh | ||
/usr/local/bin/stellar_init_cache.sh | ||
|
||
exec /usr/bin/stellar-core $@ |
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,34 @@ | ||
#!/bin/bash | ||
|
||
set -ue | ||
|
||
_init_cache=false | ||
|
||
case $STELLAR_CORE_HISTORY_CACHE_TYPE in | ||
gcloud) | ||
echo "Stellar core cache will be stored on GCloud Storage." | ||
if ! gsutil -q stat ${STELLAR_CORE_HISTORY_CACHE_PATH%/}/.well-known/stellar-history.json | ||
then | ||
_init_cache=true | ||
fi | ||
;; | ||
local) | ||
echo "Stellar core cache will be sored locally." | ||
|
||
if [ ! -e ${STELLAR_CORE_HISTORY_CACHE_PATH%/}/.well-known/stellar-history.json ] | ||
then | ||
_init_cache=true | ||
fi | ||
;; | ||
*) | ||
echo "Unknown storage type for Stellar Core" | ||
;; | ||
esac | ||
|
||
# Stellar core checks history archive cache before initializing one. | ||
if [ "X$_init_cache" == "Xtrue" ] | ||
then | ||
stellar-core --newhist cache --conf /etc/stellar/stellar-core.cfg | ||
else | ||
echo "Skipping Stellar core cache creation." | ||
fi |
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 -ue | ||
|
||
if psql "${STELLAR_CORE_DATABASE_URL#postgresql://}" -c "\dt" | grep -q "No relations" ; then | ||
echo -n "Database is not initialized. Initializing... " | ||
stellar-core --newdb --conf /etc/stellar/stellar-core.cfg && echo "done!" | ||
|
||
exit $? | ||
fi | ||
|
||
echo "Database was already initialized. Skipping." |
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,41 @@ | ||
|
||
HTTP_PORT=11626 | ||
PUBLIC_HTTP_PORT=true | ||
LOG_FILE_PATH="" | ||
|
||
NETWORK_PASSPHRASE="Test SDF Network ; September 2015" | ||
|
||
KNOWN_PEERS=[ | ||
"core-testnet1.stellar.org", | ||
"core-testnet2.stellar.org", | ||
"core-testnet3.stellar.org"] | ||
|
||
DATABASE="postgresql://dbname=stellarcore host=postgres user=postgres password=password" | ||
UNSAFE_QUORUM=true | ||
FAILURE_SAFETY=1 | ||
CATCHUP_RECENT=8640 | ||
|
||
#The public keys of the Stellar testnet servers | ||
[QUORUM_SET] | ||
THRESHOLD_PERCENT=51 # rounded up -> 2 nodes out of 3 | ||
VALIDATORS=[ | ||
"GDKXE2OZMJIPOSLNA6N6F2BVCI3O777I2OOC4BV7VOYUEHYX7RTRYA7Y sdf1", | ||
"GCUCJTIYXSOXKBSNFGNFWW5MUQ54HKRPGJUTQFJ5RQXZXNOLNXYDHRAP sdf2", | ||
"GC2V2EFSXN6SQTWVYA5EPJPBWWIMSD2XQNKUOHGEKB535AQE2I6IXV2Z sdf3"] | ||
|
||
# [HISTORY.cache] | ||
# get="cp /var/lib/stellar/history-cache/{0} {1}" | ||
# put="cp {0} /var/lib/stellar/history-cache/{1}" | ||
# mkdir="mkdir -p /var/lib/stellar/history-cache/{0}" | ||
[HISTORY.cache] | ||
get="gsutil cp gs://YOURBUCKETNAME/{0} {1}" | ||
put="gsutil cp {0} gs://YOURBUCKETNAME/{1}" | ||
|
||
[HISTORY.h1] | ||
get="curl -sf http://s3-eu-west-1.amazonaws.com/history.stellar.org/prd/core-testnet/core_testnet_001/{0} -o {1}" | ||
|
||
[HISTORY.h2] | ||
get="curl -sf http://s3-eu-west-1.amazonaws.com/history.stellar.org/prd/core-testnet/core_testnet_002/{0} -o {1}" | ||
|
||
[HISTORY.h3] | ||
get="curl -sf http://s3-eu-west-1.amazonaws.com/history.stellar.org/prd/core-testnet/core_testnet_003/{0} -o {1}" |
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,11 @@ | ||
#!/bin/bash | ||
# wait-for-postgres.sh | ||
|
||
set -eu | ||
|
||
until psql "${STELLAR_CORE_DATABASE_URL#postgresql://}" -c '\q'; do | ||
>&2 echo "Postgres is unavailable - sleeping" | ||
sleep 1 | ||
done | ||
|
||
>&2 echo "Postgres is up - continuing" |