Markdown documentation for the latest release
User Guide - Table of Contents
Each project has three level of configuration:
projects/YOUR_PROJECT/project_configuration.yml
).projectrc
file)A .projectrc file (created in the root of the project) can customize most of options by overriding configurations at project and RAPyDo levels
Here a typical .projectrc
file:
project: your_project
# stack: your_custom_stack
hostname: localhost
# production: True
project_configuration:
variables:
env:
SMTP_ADMIN: your@email.org
other variabiles...
In every project there is a set configurations that you would like to use to switch. Even if not the case, there should be at least two modes:
development
for local development (verbose logs, auto reload and no reverse proxy)production
for deploying the project in production (less logs, gunicorn
and a reverse proxy, all configured to use SSL
, integration with Let’s Encrypt for issuing of SSL certificates).Stacks are just implemented as YAML
files based on the docker compose
syntax. You can create as many custom stacks as you need.
The final configuration you will use in every RAPyDo command is based on:
projects/YOUR_PROJECT/confs/commons.yml
)projects/YOUR_PROJECT/confs/YOUR_STACK.yml
)Default stacks (development and production) are automatically enabled
You can enable production stack by passing --production/--prod
option to any RAPyDo command or by setting production: True
in your .projectrc
. You can enable any other custom stack by passing --stack STACK_NAME
to any RAPyDo command or by setting stack: STACK_name
in your .projectrc
.
RAPyDo is containers oriented and this means that every service can be easily added to be tested locally. We tested several services in our projects thus they are already integrated:
More services can be added as long as you can provide a container image (official or not) for it; so basically always!
In a stack (e.g. in production) you may choose to switch to external existing services by simply overriding the SERVICE configuration (HOST, PORT, etc), without changing your endpoint code.
The OpenAPI standard has helped us many times to show to clients the experience of HTTP API services without even using a frontend. This is why every endpoint defined with RAPyDo is fully OpenAPI-compliant and included in a Swagger specification file available at the /api/swagger endpoint.
All core RAPyDo images are automatically built and pushed to the Docker Hub. You can download all required images by using the rapydo pull
command. A project can extend a base image (e.g. to install additional libraries required for custom endpoints). Custom images can be built by using the rapydo build
command.
Some interfaces can be launched as containers to help with many services, such as swaggerui to inspect OpenAPI specs and adminer to access PostgreSQL, MySQL/MariaDB.
All interfaces can be executed by using the rapydo run
command.
The same repository can host different projects. This action came handy quite a lot of times when a similar project has to be maintained in the same repository by the same people.
If the project is only one it is used as default. To switch projects you can use the --project
command line parameter or set it inside the .projectrc
file.
In production mode an additional container based on NGINX is automatically included to your stack. NGINX is a reverse proxy ensuring security and additional performances to your project. Furthermore it support SSL certificates to enable HTTPS connections.
Production mode can be enabled command line by adding the --production
/ --prod
flag. To ensure the option is always activated you can save it in a .projectrc
file by adding:
production: True
Also, in production mode a container based on fail2ban
will be automatically added to your stack, to protect your endpoints and services from brute force attacks or bots scanning for potential vulnerabilities.
RAPyDo supports Let’s Encrypt to automatically deploy SSL certificates. Once started your project in production mode you can request for a SSL certificate with the following command:
rapydo ssl
To let this command properly works please verify that:
.projectrc
.projectrc
To issue a certificate the nginx container is expected to be running (already started with rapydo start
). If you want to issue a certificate without starting the container, you can use rapydo ssl --volatile
Let’s Encrypt certificates expire in 90 days, you can renew them by executing again the rapydo ssl
command.
To make sure your certificate is always up-to-date you can setup a cronjob to automatize the certificate renew.
Crontab have some limitations due to the simplified environment used to execute commands, to overcome that limitations you have to:
The following crontab entry is able to renew the SSL certificate every Monday at 00:00 AM
PATH=/home/ubuntu/.local/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin
0 0 * * 1 cd /your/project/path && rapydo ssl > /your/project/path/data/logs/ssl.log 2>&1
or
0 0 * * 1 cd /your/project/path && /path/to/bin/rapydo ssl > /your/project/path/data/logs/ssl.log 2>&1
If you already have a working deployment of your project (let’s name it YOUR_PROJECT) based on version X and you want to upgrade to the new version Y, you have to:
1 - Stop the current stack
rapydo remove
2 - Switch your git branch to the new version X
git fetch && git checkout X
3 - Upgrade your RAPyDo controller
rapydo install
By default, the install command will understand by itself which version is required by YOUR_PROJECT. Otherwise you can specify a specific version with rapydo install version
4 - Reinitialize your project
rapydo init
This step will verify your submodules and will switch them to the correct branch if required.
5 - Update your submodules
rapydo update
This step is usually not needed when submodules are switched to a new version, but it is useful in any other case. You can safely add to your swiss-knife box and execute it in any case.
To skip updates of your main branch and only update your submodules: rapydo update -i main
6 - Pull updated base images
You can download updated base images with the rapydo pull
command. This command will automatically fetch these images from the Docker Hub
7 - Build project images (optional)
If your project extends the base images you can build them with the rapydo build
. This step is always optional, custom images will be automatically built when the stack will be executed if not previously built.
8 - Upgrade completed
Your upgrade procedure is now completed, you are able to start your stack with rapydo start
RAPyDo 2.2 upgraded the PostgreSQL version from 13.4 to 14.1. Databases created with psq13 are not compatible with psq14 and your container will fail to start with the following error:
FATAL: database files are incompatible with server
DETAIL: The data directory was initialized by PostgreSQL version 14, which is not compatible with this version 14.1.
Based on the Official Upgrading Guide, to upgrade your database you have to restore a dump of your DB on the new engine. To ease the process RAPyDo includes a utility script (version_upgrade
) bundled with the PostgreSQL build that automatically performs most of the steps needed to upgrade. If your database is only used to store sessions you can simply destroy the database volume and re-initialize it. Otherwise you can perform a backup of your current database and then use the version_upgrade
utility to restore the backup on the new version.
data/backup/postgres/
. Make sure to have a very recent backup of your db. You can also list your backups with rapydo restore postgres
rapydo backup postgres
rapydo run --debug postgres
version_upgrade
to start the upgrade process and follow the instructions. The command will list your available backup files, to start the upgrade on a specific backup execute version_upgrade backupfilename.sql.gz
The same issue already happened with RAPyDo 0.9 with the upgrade of PostgreSQL from 12 to 13 and the same will happen again when we will upgrade from version 14 to version 15
RAPyDo 2.0 upgraded neo4j from 4.2 to 4.3 and according to neo4j official documentation a database conversion is needed.
To execute the upgrade:
1) start neo4j in upgrade mode rapydo -e NEO4J_ALLOW_UPGRADE=True -s neo4j start
2) your database is now upgraded, you can execute your stack as usual