Skip to main content

Databases and Redis

The Full Stack Quick Start runs a MariaDB container for each service and one Redis container. This page covers replacing them with databases and Redis that you manage.

Settings on this page are given as environment variables, except where a setting is in another file. For other ways to configure the services, see Configuration Mechanics.

Requirements​

StoreUsed bySupported versions
Relational databaseCore, BFF, Bridge, WRPRMariaDB 10.11.3 or later, or PostgreSQL 18.3 or later
Redis-compatible storeBFF, oauth2-proxyCompatible with Redis 7.0.11 or later

Each service needs its own database. The databases are independent of each other, so different services can use different supported engines or versions.

Databases​

Preparing a database​

For each service, create an empty database and a user for the service. The service creates and updates its own tables, so the user needs permission to create and change tables, not only to read and write data. For how to create databases and users, see your database vendor's documentation.

Connecting a service​

ServiceSettingsQuick start location
CoreONE_app__databaseUrlenv/.core.env
BFFspring.datasource.url, spring.datasource.username, spring.datasource.passwordenv/.bff.env
Bridgespring.datasource.url, spring.datasource.username, spring.datasource.passwordenv/.bridge.env
WRPRspring.datasource.url, spring.datasource.username, spring.datasource.passwordenv/.wrpr.env

Core takes the credentials as part of ONE_app__databaseUrl. For MariaDB, the URL starts with mysql://. Core connects using the MySQL protocol, which MariaDB supports.

BFF, Bridge, and WRPR take the credentials as separate settings. In the starter setup, the images build the database URL from MYSQL_* variables, with a fixed port of 3306. Set the three settings above directly instead, and remove the MYSQL_* variables. The URL starts with jdbc:mariadb:// or jdbc:postgresql://.

Each service keeps a pool of connections to its database. The pool size applies to each instance of a service, so if you run several instances, your database must accept enough connections for all of them. For pool settings, see the Core, BFF, WRPR, and Bridge configuration references.

Schema migrations​

Each service updates its database schema when it starts, by running the migrations included in its version. Note the following:

  • Migrations cannot be undone. To return to an earlier version, restore a backup taken before the upgrade. Back up each database before you upgrade a service.
  • Migrations are not designed to run from several instances at the same time. Do not start several instances of a service at once against a new or upgraded database.

Core can run migrations separately from the server. Add one of these flags to the command of the core service:

FlagEffect
--only-migrationMigrates the database, then exits.
--skip-migrationStarts the server without migrating. The database must already be migrated.

For example, run Core once with --only-migration, then start your Core instances with --skip-migration.

Redis​

oauth2-proxy and BFF require a Redis-compatible store. You can use Redis or any compatible service, such as Valkey or a managed service from your cloud provider. Both services can use the same instance, as in the quick start.

ServiceDataIf the data is lost
oauth2-proxyOperator sessionsOperators are signed out.
BFFMappings of sessions to rolesThe mappings are rebuilt. The first requests take longer.

The services do not need this data to survive a restart, so persistence is not required.

Connecting to Redis​

ServiceSettingsQuick start location
BFFREDIS_HOST, REDIS_PORT, REDIS_DB, REDIS_PASSWORDenv/.bff.env
oauth2-proxyredis_connection_urlconf/oauth2_proxy/oauth2-proxy.cfg

Keep session_store_type = "redis" in oauth2-proxy.cfg. For the connection URL format, including credentials and TLS, see the oauth2-proxy session storage documentation.

Removing the starter containers​

After a service connects to your own database or Redis, remove the starter container from docker-compose.yml: its service entry, its entries under depends_on, and its volume, if it has one.