Databases

Boxfuse is able to automatically provision both PostgreSQL and MySQL databases locally and on AWS RDS. Boxfuse exposes the database URL, user and password as environment variables within the application instances. And if your application is based on Spring Boot, Grails, Play or Dropwizard, Boxfuse will automatically configure your frameworks's default datasource with those settings.

This is a great fit for microservices that follow the database per service:

Database per service

dev environment

Locally on your machine, for your dev environment Boxfuse installs and launches a dev VM that contains a fully-configured PostgreSQL database. The PostgreSQL service from that VM is then exposed to your app by mapping its port.

test and prod environments

On AWS, for your test and prod environment Boxfuse automatically provisions either single- or multi-AZ RDS instances for your application.

To ensure your infrastructure can survive in the face of failure, Boxfuse can make your RDS database highly available by provisioning a continuously replicated geo-redundant hot standby spare instance that's ready take over in case the primary one fails.

To achieve this you can simply scale your database in the Boxfuse Console:

Environment Variables

Boxfuse automatically exposes the correct database URL, user and password for the database of your app in the current environment as environment variables within your instance:

JVM apps

Environment Variable Name Description Example
BOXFUSE_DATABASE_URL The JDBC URL jdbc:postgresql://my-app-prod-db.ca53c5vrhrzn.eu-central-1.rds.amazonaws.com:5432/my_app_db?ssl=true
BOXFUSE_DATABASE_USER The database user kgbdvfcbweikgewVBZUWKSVBvwzwkvbVIVW
BOXFUSE_DATABASE_PASSWORD The database password OIHQGikugfdieweqwfgUFuDuzkDtERwTSCHJdfIZtdziDjZdtTIdZTUtDSdikdfOULOpOiHhiUGIOgOiGFOFfUI

Node.js apps

Environment Variable Name Description Example
BOXFUSE_DATABASE_HOST The database host my-app-prod-db.ca53c5vrhrzn.eu-central-1.rds.amazonaws.com
BOXFUSE_DATABASE_PORT The database port 5432
BOXFUSE_DATABASE_NAME The database port my_app_db
BOXFUSE_DATABASE_USER The database user kgbdvfcbweikgewVBZUWKSVBvwzwkvbVIVW
BOXFUSE_DATABASE_PASSWORD The database password OIHQGikugfdieweqwfgUFuDuzkDtERwTSCHJdfIZtdziDjZdtTIdZTUtDSdikdfOULOpOiHhiUGIOgOiGFOFfUI
BOXFUSE_DATABASE_CA_CERT The CA root certificate to use to connect via TLS (SSL) /cacerts/rds.pem

Security

The user provided has superuser privileges.

All database connection use SSL (TLS). Every Boxfuse instances comes with RDS root certificates out of the box.

Auto-configuration

If your application is based on Spring Boot, Grails, Play or Dropwizard, Boxfuse will automatically configure your framework's default datasource with the correct database driver class name, URL, user and password.

Schema evolution / database migration

Evolving your schema works best with Flyway.

We strongly recommend you apply datbase migrations on application startup. You can either use a plugin for your framework of choice or call Flyway programmatically:

Flyway flyway = new Flyway();
flyway.migrate();

Flyway 4.0 and newer comes with out of the box support for Boxfuse. When running inside a Boxfuse instance Flyway will automatically pick up the database URL and credentials exposed by Boxfuse.

Character encoding

These are the default character encodings for the databases created by Boxfuse:

DatabaseCharacter encoding
PostgreSQLUTF8
MySQLutf8mb4

Time Zones

All databases created by Boxfuse are created with their time zone set to UTC.

Manual connections

You can manually connect to the correct database for each environment by using the open -db command. This will automatically create a secure connection using your database's native client:

> boxfuse open -db -env=test

Launching psql to access the myuser/myapp PostgreSQL database in the test environment ...
psql (9.4.5, Server 9.4.5)
SSL Connection (Encryption cipher: ECDHE-RSA-AES256-SHA, Bits: 256)
Type „help“ for help.

myapp=>

Alternatively you can obtain the url and credentials of your database for each environment where your app is currently deployed by using the info command.

> boxfuse info -env=test

Info about myuser/myapp in the test environment:

App Type    : Single Instance with Zero Downtime updates
App URL     : http://myapp-test-myuser.boxfuse.io/
DB Type     : PostgreSQL database
DB URL      : jdbc:postgresql://boxdb-myuser-test-myapp.ca53c5vrhrzn.eu-central-1.rds.amazonaws.com:5432/myapp
DB Host     : boxdb-myuser-test-myapp.ca53c5vrhrzn.eu-central-1.rds.amazonaws.com
DB Port     : 5432
DB Database : myapp
DB User     : qbGh5bYandLAYiXBHXp5L8jQliU9qwAkEFRf1R7JzJJ3azNwWmauKfYJe1TCoUW
DB Password : JDBsCkFuDUCqLwDhbWZcZWmaeFCN7W8aAIzy0MjYA5ICXKCf3zMO7azw9092VFFqsnKayqWefAaklZchfATAbLsvShdsOWjKJBaU
DB Status   : available

File Storage