The Gobierto Developer Hub

Welcome to the Gobierto developer hub. You'll find comprehensive guides and documentation to help you start working with Gobierto as quickly as possible, as well as support if you get stuck. Let's jump right in!


Server installation guide

In this tutorial we are going to show you how to install Gobierto in a simple Linux server.

Server requirements:

  • 6 Gb RAM as a minimum
  • 40 Gb HD as a minimum
  • 2 x CPU cores

Software requirements:

  • Linux OS (we recommend Ubuntu LTS 20.04)
  • Ruby 2.7.1 (we recomend installing Ruby with rbenv)
  • Rubygems
  • Postgresql >= 12
  • ElasticSearch 2.4.x
  • Memcached
  • Redis
  • Webserver (we recommend Nginx)
  • Dependencies (to be installed using apt-get):
    • build-essential
    • git
    • psmisc
    • gnupg
    • zip
    • ruby-dev
    • imagemagick
    • libpq-dev
    • nodejs (>= 12.x)
    • libicu-dev (libicu-devel in other Linux distributions)

PostgreSQL, ElasticSearch, Memcached, Redis and the webserver must be up and running

External requirements:

  • Amazon AWS S3 keys
  • Rollbar, as exception notification tool (you can replace it easily)
  • An account in Cloudinary. You'll need the API keys.

We recommend you to prepare the credentials from these services before you continue with this

Database setup

Create the database: createdb gobierto.

Application setup

We have our preferences about which folders to use and with which permissions and users the application should be installed,
and this guide is going to follow those conventions. Feel free to adapt the guide to your infrastructure and personal perferences

Setup folders

  1. Choose a destionation folder and create it. In our case, we prefer /var/www/gobierto:
  • /var/www/gobierto/
  • /var/www/gobierto/shared
  • /var/www/gobierto/shared/bundle
  • /var/www/gobierto/shared/config
  • /var/www/gobierto/shared/log
  • /var/www/gobierto/shared/public
  • /var/www/gobierto/shared/tmp
  • /var/www/gobierto/shared/vendor
  • /var/www/gobierto/releases
  • /var/www/gobierto/repo
  1. Copy .env.example to /var/www/gobierto/shared/.rbenv-vars and fill all the variables following this guide.

  2. Create /var/www/gobierto/shared/config/database.yml with the following content:

  adapter: postgresql
  encoding: unicode
  database: gobierto
  pool: 5
  username: postgres
  1. Deploy the site

Back to your development environment, we are going to deploy the site, following these steps:

  1. Check the server configuration: $ bundle exec cap production deploy:check

  2. Deploy! $ bundle exec cap production deploy

  3. In the remote server, check that /var/www/gobierto/current/ has been created as a symlink

Notice that you can change the way to deploy the application. We prefer Capistrano and that's the configured option, but if you want to deploy in a different way just update the code in the fork of your project and that's all.

  1. (optional) Load budgets data

Once the application is working in production (without working in the HTTP server yet) we need to
load budgets data (if you enable the budgets module).

Please, refer to Gobierto budgets data load page for further information.

  1. Configure and enable the server virtual host. You can use this file as template, with SSL configuration:
server {
  listen        80 default_server;
  server_name   _;

  root /var/www/gobierto/current/public;

  rails_env production;

  location / {
    return  301 https://$host$request_uri;

server {
  listen 443;
  server_name   _;

  ssl on;
  ssl_certificate /etc/ssl/certs/gobierto.es.chained.crt;
  ssl_certificate_key /etc/ssl/private/gobierto.key;

  passenger_enabled on;
  client_max_body_size 50M;

  access_log      /var/log/nginx/presupuestos-gobierto_access.log;
  error_log       /var/log/nginx/presupuestos-gobierto_error.log;

  root /var/www/gobierto/current/public;

  rails_env production;

  location ~ ^/(assets|packs)/ {
    try_files $uri =404;
    expires max;
    add_header Cache-Control public;
    gzip_static on;
    add_header Last-Modified "";
    add_header ETag "";

  location ~* \.(?:ico|css|js|gif|jpe?g|png)$ {
    try_files $uri =404;
    log_not_found off;

  location @passenger_root {
      root /var/www/gobierto/current/public;

Remember to update the domains (updating the variable server_name) according to your needs.

Also, configure or disable GOBIERTO_FORCE_SSL env var to force SSL in the application.

  1. Once you reload the webserver to read the new configuration you should be able to see the site up and running.

  2. If you want to enable memcached storage Gobierto supports it:

  • set GOBIERTO_CACHE_TYPE to mem_cache_store if you want to enable memcached
  • set GOBIERTO_CACHE_MEMCACHE_HOST to a valid host if your memcached is in a different server


Once the application is installed, it's convenient to generate and store backups periodically. There are 3 main data sources for backups:

1. Application log

In application log the requests sent to the application, the processes and database queries generated as consequence of the requests and the responses to the requests are recorded. If the setup folders instructions of this guide has been followed, the application log can be found in /var/www/gobierto/shared/log/.
The name of the log file uses the application environment, so it is production.log if the application is installed in production environment. It's recommended to rotate daily the log file due to the verbosity of the application. To do this you can setup logrotate by setting in /etc/logrotate.d/gobierto

/var/www/gobierto/shared/log/production.log {
    rotate 30
    dateformat -%Y%m%d-server_name
        touch /var/www/gobierto/current/tmp/restart.txt

In this way the most recent activity of the log is in an uncompressed file with a .log extension and the entries from previous days are in compressed files with names containing with the same date of the contained activities.

2. Files uploaded with the application

Depending on the installation they can be found in the file system in which the application is located, in /var/www/gobierto/shared/public/system/attachments/ or in a cloud storage service as s3.

3. Database

It's recommended to store periodically database dumps. To do this, use pg_dump instruction is invoked. If the database user employed to create the application database is called postgres, the database is called gobierto as recommended in this guide and the database is installed in the same machine as the application the instruction to generate a dump can be:

pg_dump -U postgres -Fc -f backup_location/gobierto-date.sql.gz -Z 9 -U postgres gobierto.

The backup_location can be a directory located in the home path of the user executing the instruction and date is recommended to use the same format as the log rotation: %Y%m%d (e.g. 20191231)

If the database is installed on a different machine and port, for example database.server.org:5442 add a pair of options:

pg_dump -U postgres -h database.server.org  -p 5442 -Fc -f backup_location/gobierto-date.sql.gz -Z 9 -U postgres gobierto


If you have any question, please reach to us in [email protected] or create an issue in the
repository. We'll get back to you ASAP.

Updated 8 months ago

Server installation guide

Suggested Edits are limited on API Reference Pages

You can only suggest edits to Markdown body content, but not to the API spec.