For Developers (Under construction)#
Guidelines#
Welcome to the guidelines EUDAT’s instrument registry service (B2INST) for Developers.
B2INST needs connection to a list of external services: redis, elasticsearch,
a database (postgresql or mysql), and rabbitmq. To simplify the creation of
this necessary execution environment, the Docker application engine is used.
The default Docker configuration for B2INST will try to mount a folder from
the host machine. This host directory is designated by the environment
variable $B2SHARE_DATADIR
which should be an absolute path. This folder
is used to store all the data uploaded into B2INST and is therefore very
important.
B2INST has a set of configuration parameters, which should be inspected and
changed when necessary by the site administrator. On the first run of the
service, a configuration file will be created in the B2INST data location
(which also by default is mounted to the host folder
${B2SHARE_DATADIR}/b2share-data/
as described above). The name of this
configuration file is b2share.cfg
. Please note that after each update of
this file the service needs to be restarted
(with e.g.docker-compose restart
) for the changes to take effect.
By default, the B2INST service will use a newly created postgresql database.
This database’s data is persisted in ${B2SHARE_DATADIR}/postgresql-data/
.
In case you want to use an external database, one can be configured
by editing the b2share.cfg
file and defining the
SQLALCHEMY_DATABASE_URI
variable. For example, for a postresql database,
use SQLALCHEMY_DATABASE_URI =
"postgresql://db_username:db_password@db_host/db_name"
)
Note that you also need to remove the B2SHARE_SQLALCHEMY_DATABASE_URI
variable in the docker-compose.yml
file.
B2INST uses nginx as the front-end HTTP server, responsible for establishing
secure connections with clients over https. By default an autogenerated
security certificate is used, which triggers security warnings in the client
browsers. For a production server it is recommended to use a
valid certificate. To use it with nginx, place the certificate files in an
empty folder on the host machine (e.g. /b2share-etc/ssl
) and mount the
folder in the nginx container by updating the volumes
declaration in the
docker-compose.yml
file. Make sure that the following files are present in
the mounted folder:
ssl_certificate /b2share-etc/ssl/b2share.crt
ssl_certificate_key /b2share-etc/ssl/b2share.key
In order to project locally (without Docker), a Python installation and the installation
of various packages are required. The preffered Python version is 3.6
:
$ sudo add-apt-repository ppa:deadsnakes/ppa
$ sudo apt-get update
$ sudo apt-get install python3.6 python3.6-dev python3-virtualenv python3.6-distutils build-essential libffi-dev
Create a virtual environment and activate it:
$ virtualenv -p /usr/bin/python3.6 venv
$ source venv/bin/activate
Now we can install B2INST for development with pip
$ pip install --upgrade pip setuptools==57.5.0 wheel
$ pip install -r requirements.txt
$ pip install -e .[all]
Last update: 15.08.2024