Skip to content

Commit 8a8337a

Browse files
author
Jan Waś
committed
Add a script for starting the Trino container
It's not used in the CI workflows yet, because they're optimized to only include the connectors used in the particular workflow.
1 parent 8dfe506 commit 8a8337a

File tree

2 files changed

+80
-0
lines changed

2 files changed

+80
-0
lines changed

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,10 @@ dist
109109
# custom Trino connectors
110110
/trino-rest-github-*
111111
/trino-git-*
112+
/bin/trino-rest-github-*
113+
/bin/trino-git-*
114+
/bin/config.properties
115+
/bin/hive-cache
112116

113117
# Jekyll
114118
_site

bin/run-trino.sh

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
#!/usr/bin/env bash
2+
#
3+
# Start a Trino container with additional connectors and catalogs
4+
# configured and wait for it to be ready.
5+
6+
set -euo pipefail
7+
8+
for cmd in curl unzip docker; do
9+
if ! command -v "$cmd" >/dev/null; then
10+
echo >&2 "Missing the $cmd command"
11+
exit 1
12+
fi
13+
done
14+
15+
if [ -z "$AWS_REGION" ] || [ -z "$AWS_ACCESS_KEY_ID" ] || [ -z "$AWS_SECRET_ACCESS_KEY" ] || [ -z "$GITHUB_TOKEN" ]; then
16+
echo >&2 "Following environmental variables need to be set: AWS_REGION, AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY, GITHUB_TOKEN"
17+
exit 1
18+
fi
19+
20+
CONTAINER_NAME=trino
21+
TRINO_VERSION=455
22+
TRINO_GIT_VERSION=0.83
23+
TRINO_REST_VERSION=0.154
24+
25+
SCRIPT_DIR="$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" &>/dev/null && pwd)"
26+
cd "$SCRIPT_DIR" || exit 1
27+
28+
if [ ! -d trino-git-$TRINO_GIT_VERSION ]; then
29+
curl -fLOsS https://github.com/nineinchnick/trino-git/releases/download/v$TRINO_GIT_VERSION/trino-git-$TRINO_GIT_VERSION.zip
30+
unzip trino-git-$TRINO_GIT_VERSION.zip
31+
fi
32+
33+
if [ ! -d trino-rest-github-$TRINO_REST_VERSION ]; then
34+
curl -fLOsS https://github.com/nineinchnick/trino-rest/releases/download/v$TRINO_REST_VERSION/trino-rest-github-$TRINO_REST_VERSION.zip
35+
unzip trino-rest-github-$TRINO_REST_VERSION.zip
36+
fi
37+
38+
cat <<EOF >config.properties
39+
coordinator=true
40+
node-scheduler.include-coordinator=true
41+
http-server.http.port=8080
42+
discovery.uri=http://localhost:8080
43+
query.max-memory-per-node=4086929818B
44+
EOF
45+
46+
mkdir -p "$SCRIPT_DIR"/hive-cache
47+
chmod 777 "$SCRIPT_DIR"/hive-cache
48+
docker run \
49+
-v "$SCRIPT_DIR"/config.properties:/etc/trino/config.properties \
50+
-v "$SCRIPT_DIR"/trino-git-$TRINO_GIT_VERSION:/usr/lib/trino/plugin/git \
51+
-v "$SCRIPT_DIR"/trino-rest-github-$TRINO_REST_VERSION:/usr/lib/trino/plugin/github \
52+
-v "$SCRIPT_DIR"/../catalog/git.properties:/etc/trino/catalog/git.properties \
53+
-v "$SCRIPT_DIR"/../catalog/github.properties:/etc/trino/catalog/github.properties \
54+
-v "$SCRIPT_DIR"/../catalog/trinocicd.properties:/etc/trino/catalog/trinocicd.properties \
55+
-v "$SCRIPT_DIR"/hive-cache:/opt/hive-cache \
56+
-v "$SCRIPT_DIR"/../sql:/sql \
57+
-e AWS_ACCESS_KEY_ID \
58+
-e AWS_SECRET_ACCESS_KEY \
59+
-e AWS_REGION \
60+
-e GITHUB_TOKEN \
61+
-p 8080:8080 \
62+
--name $CONTAINER_NAME \
63+
-d \
64+
trinodb/trino:$TRINO_VERSION
65+
66+
i=0
67+
until status=$(docker inspect $CONTAINER_NAME --format "{{json .State.Health.Status }}") && echo "$status" | grep -q '"healthy"'; do
68+
if [[ $((i++)) -ge 10 ]]; then
69+
echo >&2 "🚨 Too many retries waiting for Trino to start"
70+
exit 1
71+
fi
72+
echo >&2 "Status is: $status, sleeping 10 seconds"
73+
sleep 10
74+
done
75+
76+
echo >&2 "Status is: $status, connect to trino://localhost:8080/trinocicd/v2"

0 commit comments

Comments
 (0)