We removed our free Sandbox April 25th.
You can read more on our blog.
PostgreSQL and PostGIS¶
If your application requires a PostgreSQL database, all you need to do is to add the following lines to your dotcloud.yml Build Files:
data: type: postgresql
If you want to have a PostgreSQL server with PostGIS extensions, specify postgis instead:
data: type: postgis
You can give your database or cache service any name you like instead of “data”. If for some reason your application needs multiple databases, you can either use multiple independant services (by repeating the database section multiple times in dotcloud.yml, each with a different name instead of just “db”), or create multiple users and databases inside one single service. The first option (multiple services) will bring more resources, but keep in mind that when you go to production, this will generally incur higher costs as well.
Your data service will be globally available. This means that you can use it with applications running on other platforms.
If for some reason, you want to use DotCloud just to deploy a standalone data service, create a two-lines “dotcloud.yml” file in an empty directory, and from this directory, just run:
$ dotcloud create mynicedb $ dotcloud push mynicedb $ dotcloud info mynicedb.data
In less than one minute, your data service will be up and running, and the “dotcloud info” command will show its connection credentials.
Configure Your Application¶
There are two ways to configure your app to use your new data service:
- manually, by hard-coding the host, port, user and password;
- automatically, by retrieving those parameters from the Environment File.
Check your service parameters using “dotcloud info”:
$ dotcloud info ramen.data cluster: wolverine config: postgresql_password: wG2UEFXShR created_at: 1310523915.2204001 ports: - name: ssh url: ssh://firstname.lastname@example.org:7962 - name: sql url: pgsql://root:wG2UEFXShR@59196556.dotcloud.com:7963 state: running type: postgresql
You can use the “root” user, or create your own users if you prefer. If you want to create the user “joe”, run the following command:
$ dotcloud run ramen.data -- createuser joe --pwprompt
This will create the user “joe” and prompt you for a password for this new user. Be sure to pick a secure password.
You can also decide to use the default “template1” database, or create your own. If you want to create your own database, you can run the following command:
$ dotcloud run ramen.data -- createdb mydb
And, if you want it to belong to the “joe” user created in the previous step:
$ dotcloud run ramen.data -- createdb -O joe mydb
When your application is built by the DotCloud platform, a file named environment.json is created in the home directory of each of your services.
This file contains a JSON-formatted dictionary with most of the configuration informations of the services in your stack. You can use it to retrieve automatically the host, port, and password, of your databases, caches, and so on.
You will find snippets of code to retrieve the connection information of your databases in the Environment Guide.
Your ramen.data service will expose the following variables:
Note that DATA will be replaced by the (upper-cased) name of your service.