Skip to content

Environment Variable Configuration

Environment variables in Sushi Gateway allow for dynamic configuration of the gateway without modifying files. This method is especially useful in containerized environments, enabling seamless updates and integration with external tools.

Commonly Used Environment Variables

The following table lists the key environment variables supported by Sushi Gateway:

VariableDescriptionRequiredExample ValueDefault Value
PERSISTENCE_CONFIGDefines the persistence mode (dbless for stateless, db for stateful).Yesdblessdbless
PERSISTENCE_SYNC_INTERVALThe interval (in seconds) for syncing in-memory configurations to the database.No55
DB_CONNECTION_HOSTHostname or IP address of the database server.Yeslocalhost-
DB_CONNECTION_PORTPort number of the database server.Yes5432-
DB_CONNECTION_NAMEName of the database.Yessushi-
DB_CONNECTION_USERUsername for the database.Yespostgres-
DB_CONNECTION_PASSPassword for the database user.Yesmysecretpassword-
CONFIG_FILE_PATHPath to the config.json file for declarative configurations.No/app/config.json/app/config.json
ADMIN_USERUsername for the Admin API.Yesadminadmin
ADMIN_PASSWORDPassword for the Admin API user.Yeschangemechangeme
SERVER_CERT_PATHPath to the server certificate for HTTPS.No/path/to/cert.crt-
SERVER_KEY_PATHPath to the server private key for HTTPS.No/path/to/key.pem-
CA_CERT_PATHPath to the Certificate Authority (CA) file for mutual TLS (mTLS).No/path/to/ca.crt-

Example Configuration

Here’s an example of using environment variables to configure Sushi Gateway in a Docker container:

bash
docker run \
  --rm \
  -e PERSISTENCE_CONFIG=db \
  -e PERSISTENCE_SYNC_INTERVAL=5 \
  -e DB_CONNECTION_HOST=localhost \
  -e DB_CONNECTION_PORT=5432 \
  -e DB_CONNECTION_NAME=sushi \
  -e DB_CONNECTION_USER=postgres \
  -e DB_CONNECTION_PASS=mysecretpassword \
  -e ADMIN_USER=admin \
  -e ADMIN_PASSWORD=securepassword \
  -p 8008:8008 \
  -p 8443:8443 \
  -p 8081:8081 \
  rawsashimi/sushi-proxy:0.1

Tips for Using Environment Variables

TIP

Use a .env file to manage environment variables for local development and testing. Load it using tools like docker-compose or dotenv libraries.

TIP

Ensure sensitive variables, such as database credentials, are stored securely using secret management tools (e.g., AWS Secrets Manager, HashiCorp Vault).

TIP

Combine environment variables with declarative configurations for maximum flexibility in hybrid setups.

TIP

Validate the values of required environment variables during startup to prevent misconfiguration.

TIP

For a deeper understanding of declarative configurations, visit the Declarative Configuration Guide.

Released under the MIT License.