forked from graphprotocol/graph-node
-
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.
docker: Mover Docker images to Alpine
- Loading branch information
Showing
6 changed files
with
237 additions
and
47 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
#! /bin/bash | ||
|
||
# This file is only here to ease testing/development. The commands in this | ||
# file should ultimately be moved to the corresponding commands for Cloud Build | ||
# in the cloudbuild.*.yaml files | ||
|
||
type -p podman > /dev/null && docker=podman || docker=docker | ||
|
||
for stage in graph-node-bld \ | ||
graph-node-run \ | ||
query-node \ | ||
index-node \ | ||
graph-node-dbg | ||
do | ||
$docker build -t $stage --target $stage . | ||
done |
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 | ||
|
||
if [ -f "$1" ] | ||
then | ||
exec gdb -c "$1" /usr/local/bin/graph-node | ||
else | ||
echo "usage: debug <core-file>" | ||
exit 1 | ||
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,91 @@ | ||
#!/bin/bash | ||
|
||
save_coredumps() { | ||
core_dir=/var/lib/graph/cores | ||
datestamp=$(date +"%Y-%m-%dT%H:%M:%S") | ||
ls /core.* >& /dev/null && have_cores=yes || have_cores=no | ||
if [ -d "$core_dir" -a "$have_cores" = yes ] | ||
then | ||
exec >> "$core_dir"/messages 2>&1 | ||
echo "${HOSTNAME##*-} Saving core dump on ${HOSTNAME} at ${datestamp}" | ||
|
||
dst="$core_dir/$datestamp-${HOSTNAME}" | ||
mkdir "$dst" | ||
cp /usr/local/cargo/bin/graph-node "$dst" | ||
cp /proc/loadavg "$dst" | ||
dmesg -e > "$dst/dmesg" | ||
# Capture environment variables, but filter out passwords | ||
env | sort | sed -r -e 's/^(postgres_pass|ELASTICSEARCH_PASSWORD)=.*$/\1=REDACTED/' > "$dst/env" | ||
|
||
for f in /core.* | ||
do | ||
echo "${HOSTNAME##*-} Found core dump $f" | ||
mv "$f" "$dst" | ||
done | ||
echo "${HOSTNAME##*-} Saving done" | ||
fi | ||
} | ||
|
||
start_query_node() { | ||
export DISABLE_BLOCK_INGESTOR=true | ||
graph-node \ | ||
--postgres-url "$postgres_url" \ | ||
--ethereum-rpc $ethereum \ | ||
--ipfs "$ipfs" | ||
} | ||
|
||
start_index_node() { | ||
POD_INDEX=${pod_name##*-} | ||
|
||
# FIXME: Users should just pass this in or something | ||
# Only enable block ingestion for `index-node-<network>-0`; | ||
# disable it for all tracing and production nodes | ||
if [[ ${pod_name} != *"block-ingestor"* ]]; then | ||
export DISABLE_BLOCK_INGESTOR=true | ||
fi | ||
|
||
if [ -z $MULTIPLE_ETHEREUM_NETWORKS ]; then | ||
graph-node \ | ||
--node-id "${pod_name//-/_}" \ | ||
--postgres-url "$postgres_url" \ | ||
--ethereum-rpc "$ETHEREUM_NETWORK" \ | ||
--ipfs "$ipfs" | ||
else | ||
graph-node \ | ||
--node-id "${pod_name//-/_}" \ | ||
--postgres-url "$postgres_url" \ | ||
--ethereum-rpc $ethereum \ | ||
--ipfs "$ipfs" | ||
fi | ||
} | ||
|
||
start_combined_node() { | ||
graph-node \ | ||
--postgres-url "$postgres_url" \ | ||
--ethereum-rpc $ethereum \ | ||
--ipfs "$ipfs" | ||
} | ||
|
||
postgres_url="postgresql://$postgres_user:$postgres_pass@$postgres_host/$postgres_db" | ||
|
||
wait_for "$ipfs" -t 120 | ||
wait_for "$postgres_host:5432" -t 120 | ||
sleep 5 | ||
|
||
trap save_coredumps EXIT | ||
|
||
case "$1" in | ||
query-node) | ||
start_query_node | ||
;; | ||
index-node) | ||
start_index_node | ||
;; | ||
combined-node) | ||
start_combined_node | ||
;; | ||
*) | ||
echo "Unknown mode for start-node: $1" | ||
echo "usage: start-node (query-node|index-node)" | ||
exit 1 | ||
esac |
This file was deleted.
Oops, something went wrong.
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,83 @@ | ||
#!/bin/sh | ||
|
||
# POSIX compatible clone of wait-for-it.sh | ||
# This copy is from https://github.com/eficode/wait-for/commits/master | ||
# at commit 8d9b4446 | ||
|
||
TIMEOUT=15 | ||
QUIET=0 | ||
|
||
echoerr() { | ||
if [ "$QUIET" -ne 1 ]; then printf "%s\n" "$*" 1>&2; fi | ||
} | ||
|
||
usage() { | ||
exitcode="$1" | ||
cat << USAGE >&2 | ||
Usage: | ||
$cmdname host:port [-t timeout] [-- command args] | ||
-q | --quiet Do not output any status messages | ||
-t TIMEOUT | --timeout=timeout Timeout in seconds, zero for no timeout | ||
-- COMMAND ARGS Execute command with args after the test finishes | ||
USAGE | ||
exit "$exitcode" | ||
} | ||
|
||
wait_for() { | ||
for i in `seq $TIMEOUT` ; do | ||
nc -z "$HOST" "$PORT" > /dev/null 2>&1 | ||
|
||
result=$? | ||
if [ $result -eq 0 ] ; then | ||
if [ $# -gt 0 ] ; then | ||
exec "$@" | ||
fi | ||
exit 0 | ||
fi | ||
sleep 1 | ||
done | ||
echo "Operation timed out" >&2 | ||
exit 1 | ||
} | ||
|
||
while [ $# -gt 0 ] | ||
do | ||
case "$1" in | ||
*:* ) | ||
HOST=$(printf "%s\n" "$1"| cut -d : -f 1) | ||
PORT=$(printf "%s\n" "$1"| cut -d : -f 2) | ||
shift 1 | ||
;; | ||
-q | --quiet) | ||
QUIET=1 | ||
shift 1 | ||
;; | ||
-t) | ||
TIMEOUT="$2" | ||
if [ "$TIMEOUT" = "" ]; then break; fi | ||
shift 2 | ||
;; | ||
--timeout=*) | ||
TIMEOUT="${1#*=}" | ||
shift 1 | ||
;; | ||
--) | ||
shift | ||
break | ||
;; | ||
--help) | ||
usage 0 | ||
;; | ||
*) | ||
echoerr "Unknown argument: $1" | ||
usage 1 | ||
;; | ||
esac | ||
done | ||
|
||
if [ "$HOST" = "" -o "$PORT" = "" ]; then | ||
echoerr "Error: you need to provide a host and port to test." | ||
usage 2 | ||
fi | ||
|
||
wait_for "$@" |