Services
CAP offers a few services that can be deployed or connected with through our config file.
You can always connect to an external service by using environments variables as well. But using CAP simplifies things like framework specific logic and CAP will also handle your migrations when it manages your database connection.
Compatibility Table
| App Deployment | Cluster Deployment | External Connection | Remote Access | |
|---|---|---|---|---|
| MariaDB | ✅ | ✅ | ✅ | ✅ |
| PostgreSQL | ✅ | ✅ | ✅ | ❌ |
| MySQL | ❌ | ❌ | ✅ | ❌ |
| CockroachDB | ✅ | ✅ | ✅ | ❌ |
| Dragonfly | ✅ | ❌ | ❌ | ❌ |
| RabbitMQ | ✅ | ✅ | ❌ | ❌ |
MariaDB
To deploy a MariaDB server, define it in your services block. CAP will automatically handle the deployment, including daily backups.
services:
db:
type: mariadb
version: "10.6"
Remote Access
MariaDB can be configured to allow remote access.
services:
db:
type: mariadb
access:
enable: true
whitelist: [] # Define ips/ranges here.
You can define any ip or ip range in the whitelist array.
Predefined Databases
You can create additional databases when the MariaDB service is provisioned.
services:
db:
type: mariadb
databases:
- my_first_app
- my_second_app
Database Backups
CAP allows you to configure automated backups for your database services. These backups are typically daily and can be scheduled using cron expressions.
Warning
Manual Setup Required: Defining backup in your config.cap.yaml only configures the backup schedule. To ensure your backups are actually stored and restorable, additional manual configuration is required on the Cloudbear platform side. Please contact Cloudbear support to complete the setup for your database backups.
services:
db:
type: mariadb
backup:
enable: true
schedule: "0 2 * * *" # Daily at 2:00 AM UTC
| Property | Type | Description | Default |
|---|---|---|---|
enable |
boolean |
Whether to enable automated backups for this database. | false |
schedule |
string |
A cron expression defining when backups should occur. See YAML Schema Reference. |
MySQL
MySQL is not available for deployment directly through CAP, but you can connect to an external MySQL server. See the Connections documentation for more details.
CockroachDB & PostgreSQL
To deploy a CockroachDB or PostgreSQL server, define it in your services block.
PostgreSQL Example:
services:
pg-database:
type: postgresql
version: "14"
backup:
enable: true
schedule: "@daily"
Predefined Databases
You can create additional databases when the PostgreSQL service is provisioned.
services:
pg-database:
type: postgresql
databases:
- my_first_app
- my_second_app
CockroachDB Example:
services:
crdb:
type: cockroachdb
version: "v22.1"
backup:
enable: true
schedule: "0 3 * * *"
Warning
Manual Setup Required: Like MariaDB, defining backup for PostgreSQL and CockroachDB only configures the backup schedule. Additional manual configuration is required on the Cloudbear platform side to ensure your backups are actually stored and restorable. Please contact Cloudbear support to complete the setup.
Dragonfly (Redis Compatible)
Dragonfly is a modern, in-memory datastore that is compatible with Redis.
services:
cache:
type: dragonfly
Note
Dragonfly services do not have persistent data.
RabbitMQ
To deploy a RabbitMQ message broker, define it in your services block. When you connect an application to it, a unique vhost is automatically created for your connection.
services:
queue:
type: rabbitmq
Predefined Vhosts
You can predefine vhosts for your RabbitMQ service.
services:
queue:
type: rabbitmq
vhosts:
- my_first_vhost
- my_second_vhost
Shared Services
In some cases, you might want to define a service once and have multiple applications connect to it. This can be achieved using "Shared Services". A shared service is a service that is not tied to a specific application's lifecycle. Unlike regular services, shared services are defined at the project level and do not need to be explicitly declared in your application's config.cap.yaml file to be accessible.
Shared services are defined under the shared.services block in your config.cap.yaml. This separates them from the regular services block, which defines services that are unique to each application deployment.
Example
Here's how you might define a shared database that can be used by multiple applications:
shared:
services:
shared-db:
type: mariadb
version: "10.6"
To connect to this shared service from your application, you would then use a shared-connection in your connections block, referencing the name of the shared service.
connections:
- shared: "shared-db"
name: "db"
Note
Learn more about connecting to shared services in the Connections documentation.