Skip to content

Commit adf0b21

Browse files
authored
Fix setup issues (#538)
* Fix issue with setting GATEWAYD_VERSION which fails because git is not installed * Add more logging * Add better exit codes and comments on why the error might be happening * Add env-var to set GatewayD architecture to install * Use x86_64 to set the architecture if none is given * Fix comments
1 parent 624abee commit adf0b21

File tree

2 files changed

+72
-21
lines changed

2 files changed

+72
-21
lines changed

docker-compose.yaml

Lines changed: 25 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,11 @@ services:
1313
# If you want to install a specific version of GatewayD, you can set the
1414
# GATEWAYD_VERSION environment variable to the desired version. Otherwise,
1515
# the latest version will be installed.
16-
# - GATEWAYD_VERSION=v0.9.2
16+
# - GATEWAYD_VERSION=v0.9.5
17+
# The architecture of the GatewayD and plugins to install.
18+
# Default: amd64
19+
# Possible values: amd64 or arm64
20+
- ARCH=amd64
1721
postgres:
1822
image: postgres:latest
1923
environment:
@@ -33,25 +37,32 @@ services:
3337
retries: 5
3438
gatewayd:
3539
image: gatewaydio/gatewayd:latest
36-
command: [
37-
"run",
38-
"--config", "/gatewayd-files/gatewayd.yaml",
39-
"--plugin-config", "/gatewayd-files/gatewayd_plugins.yaml"
40-
]
40+
command:
41+
[
42+
"run",
43+
"--config",
44+
"/gatewayd-files/gatewayd.yaml",
45+
"--plugin-config",
46+
"/gatewayd-files/gatewayd_plugins.yaml",
47+
]
4148
environment:
4249
# For more information about the environment variables, see:
4350
# https://docs.gatewayd.io/using-gatewayd/configuration#environment-variables
4451
- GATEWAYD_CLIENTS_DEFAULT_ADDRESS=postgres:5432
4552
# - GATEWAYD_LOGGERS_DEFAULT_LEVEL=debug
4653
ports:
47-
- "15432:15432" # GatewayD server for PostgreSQL clients to connect to
48-
- "9090:9090" # Prometheus metrics:
49-
# http://localhost:9090/metrics
50-
- "18080:18080" # GatewayD HTTP gateway:
51-
# http://localhost:18080/swagger-ui/ for the API documentation
52-
# http://localhost:18080/healthz for the health check
53-
- "19090:19090" # GatewayD gRPC API with reflection enabled:
54-
# You can use grpcurl or grpc-client-cli to interact with it
54+
# GatewayD server for PostgreSQL clients to connect to
55+
- "15432:15432"
56+
# Prometheus metrics:
57+
# http://localhost:9090/metrics
58+
- "9090:9090"
59+
# GatewayD HTTP gateway:
60+
# http://localhost:18080/swagger-ui/ for the API documentation
61+
# http://localhost:18080/healthz for the health check
62+
- "18080:18080"
63+
# GatewayD gRPC API with reflection enabled:
64+
# You can use grpcurl or grpc-client-cli to interact with it
65+
- "19090:19090"
5566
volumes:
5667
- ./gatewayd-files:/gatewayd-files:ro
5768
links:

setup.sh

Lines changed: 47 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,26 +3,66 @@
33
# This script is used to install the required packages and download
44
# the latest version of GatewayD from GitHub and install the plugins.
55

6+
# Set the architecture to amd64 if it is not set
7+
if [ -z "${ARCH}" ]; then
8+
architecture=$(uname -m)
9+
if [[ "${architecture}" = "x86_64" ]]; then
10+
echo "Setting architecture to amd64"
11+
ARCH=amd64 && export ARCH
12+
elif [[ "${architecture}" = "aarch64" ]] || [[ "${architecture}" = "arm64" ]]; then
13+
echo "Setting architecture to arm64"
14+
ARCH=arm64 && export ARCH
15+
fi
16+
fi
17+
echo "Using architecture: ${ARCH}"
18+
19+
# Install the required packages
20+
apk add --no-cache curl git
21+
622
# Get the latest released version of GatewayD from GitHub
723
[ -z "${GATEWAYD_VERSION}" ] && GATEWAYD_VERSION=$(git ls-remote --tags --sort=v:refname "https://github.com/gatewayd-io/gatewayd" | cut -d/ -f3- | tail -n1) && export GATEWAYD_VERSION
824

25+
# Check if the GatewayD version is set
26+
if [ -z "${GATEWAYD_VERSION}" ]; then
27+
echo "Failed to set GatewayD version. Consider setting the GATEWAYD_VERSION environment variable manually."
28+
exit 126
29+
fi
30+
31+
echo "Installing GatewayD ${GATEWAYD_VERSION}"
32+
933
# Set the environment variables if they are not set
1034
[ -z "${GATEWAYD_FILES}" ] && GATEWAYD_FILES=/gatewayd-files && export GATEWAYD_FILES
1135

12-
# Install the required packages
13-
apk add --no-cache curl git
14-
1536
# Create the directory to store the gatewayd files
1637
[ -d "${GATEWAYD_FILES}" ] || mkdir "${GATEWAYD_FILES}"
1738

18-
cd "${GATEWAYD_FILES}" || exit 1
39+
# Change the directory to the gatewayd-files directory to download the GatewayD archive
40+
# and install the plugins. This will fail exit code 127 (file or directory not found).
41+
cd "${GATEWAYD_FILES}" || exit 127
1942

2043
# Download the GatewayD archive if it doesn't exist
21-
[ -f "${GATEWAYD_FILES}"/gatewayd-linux-amd64-"${GATEWAYD_VERSION}".tar.gz ] || curl -L https://github.com/gatewayd-io/gatewayd/releases/download/"${GATEWAYD_VERSION}"/gatewayd-linux-amd64-"${GATEWAYD_VERSION}".tar.gz | tar zxvf -
44+
[ -f "${GATEWAYD_FILES}"/gatewayd-linux-"${ARCH}"-"${GATEWAYD_VERSION}".tar.gz ] || curl -L https://github.com/gatewayd-io/gatewayd/releases/download/"${GATEWAYD_VERSION}"/gatewayd-linux-"${ARCH}"-"${GATEWAYD_VERSION}".tar.gz -o gatewayd-linux-"${ARCH}"-"${GATEWAYD_VERSION}".tar.gz
45+
if [ -f "${GATEWAYD_FILES}"/gatewayd-linux-"${ARCH}"-"${GATEWAYD_VERSION}".tar.gz ]; then
46+
echo "GatewayD archive downloaded successfully."
47+
else
48+
echo "GatewayD archive download failed."
49+
exit 1
50+
fi
51+
52+
# Extract the GatewayD archive
53+
echo "Extracting GatewayD archive..."
54+
tar zxvf gatewayd-linux-"${ARCH}"-"${GATEWAYD_VERSION}".tar.gz -C "${GATEWAYD_FILES}"
55+
56+
# Set execute permission for the GatewayD binary
57+
echo "Setting execute permission for the GatewayD binary..."
2258
chmod +x gatewayd
2359

2460
# Install the GatewayD plugins
25-
"${GATEWAYD_FILES}"/gatewayd plugin install --skip-path-slip-verification --output-dir "${GATEWAYD_FILES}" --plugin-config "${GATEWAYD_FILES}"/gatewayd_plugins.yaml --cleanup=false --update --overwrite-config
61+
# If the installation fails, the script will exit with exit code 126 (command invoke error).
62+
echo "Installing GatewayD plugins..."
63+
"${GATEWAYD_FILES}"/gatewayd plugin install --skip-path-slip-verification --output-dir "${GATEWAYD_FILES}" --plugin-config "${GATEWAYD_FILES}"/gatewayd_plugins.yaml --cleanup=false --update --overwrite-config || exit 126
2664

27-
# Replace the default Redis URL
65+
# Replace the default Redis URL with the Redis container URL
2866
sed -i 's/redis:\/\/localhost:6379/redis:\/\/redis:6379/' "${GATEWAYD_FILES}"/gatewayd_plugins.yaml
67+
68+
echo "GatewayD ${GATEWAYD_VERSION} and plugins installed successfully. Exiting..."

0 commit comments

Comments
 (0)