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

Make PostgreSQL and Redis connection strings configurable #627

Open
wants to merge 8 commits into
base: main
Choose a base branch
from
Open
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
12 changes: 12 additions & 0 deletions docker-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,18 @@ services:
# Possible values: amd64 or arm64
# - ARCH=amd64
- REDIS_URL=redis://redis:6379/0
# Allow custom PostgreSQL connection string
- POSTGRES_USER=postgres
- POSTGRES_PASSWORD=postgres
- POSTGRES_DB=postgres
- POSTGRES_URL=postgresql://${POSTGRES_USER}:${POSTGRES_PASSWORD}@write-postgres:5432/${POSTGRES_DB}
Comment on lines +22 to +26
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unnecessary. Explained why below.


write-postgres:
image: postgres:latest
environment:
- POSTGRES_USER=postgres
- POSTGRES_PASSWORD=postgres
- POSTGRES_DB=postgres
healthcheck:
test: ["CMD-SHELL", "pg_isready -U postgres"]
interval: 5s
Expand All @@ -34,18 +41,21 @@ services:
environment:
- POSTGRES_USER=postgres
- POSTGRES_PASSWORD=postgres
- POSTGRES_DB=postgres # Ensure consistency
healthcheck:
test: ["CMD-SHELL", "pg_isready -U postgres"]
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:
Expand All @@ -65,6 +75,8 @@ services:
# https://docs.gatewayd.io/using-gatewayd/configuration#environment-variables
- GATEWAYD_CLIENTS_DEFAULT_WRITES_ADDRESS=write-postgres:5432
- GATEWAYD_CLIENTS_DEFAULT_READS_ADDRESS=read-postgres:5432
# Use the connection string set in install_plugins
- POSTGRES_URL=${POSTGRES_URL}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not used anywhere in the setup.sh script or config files and seems unnecessary.

# - GATEWAYD_LOGGERS_DEFAULT_LEVEL=debug
ports:
# GatewayD server for PostgreSQL clients to connect to
Expand Down
4 changes: 2 additions & 2 deletions gatewayd_plugins.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ actionRedis:
enabled: false

# if enabled, the url and channel are used to connect to the Redis server.
address: localhost:6379
address: ${REDIS_URL} # Use environment variable for Redis URL
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Change this to the following, so that it gets replaced by the value of the REDIS_URL environment variable, defined here:

Suggested change
address: ${REDIS_URL} # Use environment variable for Redis URL
address: redis://localhost:6379/0

channel: gatewayd-actions

# The policy is a list of policies to apply to the signals received from the plugins.
Expand Down Expand Up @@ -72,7 +72,7 @@ plugins:
env:
- MAGIC_COOKIE_KEY=GATEWAYD_PLUGIN
- MAGIC_COOKIE_VALUE=5712b87aa5d7e9f9e9ab643e6603181c5b796015cb1c09d6f5ada882bf2a1872
- REDIS_URL=redis://localhost:6379/0
- REDIS_URL=${REDIS_URL} # Use environment variable for Redis URL
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changing these will make this file unusable if someone tries to use it outside Docker and docker-compose. Hence, you should change the setup.sh script to update this instead of changing these files directly. Also, the PostgreSQL addresses and ports are already configurable via environment variables, hence you don't need to change that.

- EXPIRY=1h
# - DEFAULT_DB_NAME=postgres
- METRICS_ENABLED=True
Expand Down