Skip to content
Snippets Groups Projects
README.md 2.04 KiB
Newer Older
# TimescaleDB Docker Image

The Dockerfile in this directory allows to create a container with a PostrgreSQL-Timescale DBMS (https://www.timescale.com/), and then initialise it with the DB schema required by the Tango Archiving framework.

The main image is pulled from the official PostgreSQL repository in the Docker Hub (https://hub.docker.com/_/postgres). This image offers several features to customize and extend itself.

## Initialization scripts

If you would like to do additional initialization in an image derived from the Postgres official one, add one or more *.sql, *.sql.gz, or *.sh scripts under /docker-entrypoint-initdb.d (creating the directory if necessary). After the entrypoint calls initdb to create the default postgres user and database, it will run any *.sql files, run any executable *.sh scripts, and source any non-executable *.sh scripts found in that directory to do further initialization before starting the service.

The script files in the directory /docker-entrypoint-initdb.d are sequentially executed following their preempted number in the filename. Hence, the first ones (000_install_timescaledb.sh and 001_timescaledb_tune.sh) are provided by default. 
The next ones have been pulled from the official Tango repository in order to create the desired DB schema. These files are in the 'resources' directory and they have been pulled from Tango-Hdbpp_Timescale_Project (https://github.com/tango-controls-hdbpp/hdbpp-timescale-project/tree/master/resources/schema):
- admin.sql creates the admin user that will create the tables
- hdb_schema.sql creates the standard Tango Archiving DB (This is the only MANDATORY script)
- hdb_roles.sql creates additional roles
- hdb_ext_aggregates.sql creates the continuous aggregate views (https://docs.timescale.com/timescaledb/latest/how-to-guides/continuous-aggregates/)
- cleanup.sql strips the SUPERUSER trait from hdb_admin
Last updates on these scripts are dated to August 2021 (more info can be found at https://github.com/tango-controls-hdbpp/hdbpp-timescale-project/blob/master/doc/db-schema-config.md)