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

Revamp docker compose #485

Merged
merged 3 commits into from
Mar 7, 2024
Merged
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
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -34,3 +34,6 @@ libtensorflow*
# Test generated files
cmd/test_*.yaml.bak
cmd/test_*.yaml

# docker-compose
gatewayd-files/
49 changes: 47 additions & 2 deletions docker-compose.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,20 @@
version: "3.8"
services:
install_plugins:
# This intermediate service is used to install the plugins
# before starting the GatewayD service.
image: alpine:3.18
command: ["/bin/sh", "/setup.sh"]
volumes:
- ./setup.sh:/setup.sh:ro
# Use the variable defined above to mount the GatewayD files.
- ./gatewayd-files:/gatewayd-files:rw
environment:
- GATEWAYD_FILES=/gatewayd-files
# If you want to install a specific version of GatewayD, you can set the
# GATEWAYD_VERSION environment variable to the desired version. Otherwise,
# the latest version will be installed.
# - GATEWAYD_VERSION=v0.9.2
postgres:
image: postgres:latest
environment:
Expand All @@ -10,18 +25,48 @@ services:
interval: 5s
timeout: 5s
retries: 5
redis:
image: redis:latest
healthcheck:
test: ["CMD", "redis-cli", "ping"]
interval: 5s
timeout: 5s
retries: 5
gatewayd:
image: gatewaydio/gatewayd:latest
command: ["run"]
command: [
"run",
"--config", "/gatewayd-files/gatewayd.yaml",
"--plugin-config", "/gatewayd-files/gatewayd_plugins.yaml"
]
environment:
# For more information about the environment variables, see:
# https://docs.gatewayd.io/using-gatewayd/configuration#environment-variables
- GATEWAYD_CLIENTS_DEFAULT_ADDRESS=postgres:5432
# - GATEWAYD_LOGGERS_DEFAULT_LEVEL=debug
ports:
- "15432:15432"
- "15432:15432" # GatewayD server for PostgreSQL clients to connect to
- "9090:9090" # Prometheus metrics:
# http://localhost:9090/metrics
- "18080:18080" # GatewayD HTTP gateway:
# http://localhost:18080/swagger-ui/ for the API documentation
# http://localhost:18080/healthz for the health check
- "19090:19090" # GatewayD gRPC API with reflection enabled:
# You can use grpcurl or grpc-client-cli to interact with it
volumes:
- ./gatewayd-files:/gatewayd-files:ro
links:
- postgres
- redis
healthcheck:
test: ["CMD", "curl", "-f", "http://gatewayd:18080/healthz"]
interval: 5s
timeout: 5s
retries: 5
depends_on:
postgres:
condition: service_healthy
redis:
condition: service_healthy
install_plugins:
condition: service_completed_successfully
28 changes: 28 additions & 0 deletions setup.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#!/bin/bash

# This script is used to install the required packages and download
# the latest version of GatewayD from GitHub and install the plugins.

# Get the latest released version of GatewayD from GitHub
[ -z ${GATEWAYD_VERSION} ] && export GATEWAYD_VERSION=$(git ls-remote --tags --sort=v:refname "https://github.com/gatewayd-io/gatewayd" | cut -d/ -f3- | tail -n1)

# Set the environment variables if they are not set
[ -z ${GATEWAYD_FILES} ] && export GATEWAYD_FILES=/gatewayd-files

# Install the required packages
apk add --no-cache curl git

# Create the directory to store the gatewayd files
[ -d ${GATEWAYD_FILES} ] || mkdir ${GATEWAYD_FILES}

cd ${GATEWAYD_FILES}

# Download the GatewayD archive if it doesn't exist
[ -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 -
chmod +x gatewayd

# Install the GatewayD plugins
${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

# Replace the default Redis URL
sed -i 's/redis:\/\/localhost:6379/redis:\/\/redis:6379/' ${GATEWAYD_FILES}/gatewayd_plugins.yaml