I have created my first real karaf-based docker image:
https://github.com/steinarb/sonar-collector#run-the-sonar-metrics-collector-in-docker
The sonar-collector is intended as a webhook called by sonar on
completing a build, it will store key sonar measurements as a row in a
database table.
Sonar has these numbers internally but doesn't have a way to get at
them. At first we typed these numbers manually into a spreadsheet to get
statistics on a set of analyzed programs. But that was tedious, so we
created sonar-collector to capture the numbers instead.
The docker image is built with maven against a local docker and then
after testing, the image was pushed to docker hub:
https://github.com/steinarb/sonar-collector#building-the-docker-image
The docker image is a very thin layer on top of the official karaf 4.2.8
docker image
https://github.com/steinarb/sonar-collector/blob/master/docker/docker/Dockerfile#L1
It copies in two files into the image's karaf etc directory:
1. org.apache.karaf.features.cfg
a. Adds a feature repository for sonar-collector
https://github.com/steinarb/sonar-collector/blob/master/docker/docker/org.apache.karaf.features.cfg#L28
b. Adds two features to the boot features
i. An enviroment variable overloadable DataSourceFactory feature
that defaults to postgresql
https://github.com/steinarb/sonar-collector/blob/master/docker/docker/org.apache.karaf.features.cfg#L52
ii. The sonar-collector-webhook-with-postgresql feature
https://github.com/steinarb/sonar-collector/blob/master/docker/docker/org.apache.karaf.features.cfg#L53
2. org.ops4j.datasource-sonar-collector.cfg which is a modified version
of the file generated by pax-jdbc on first start, and the JDBC
driver name and JDBC connection info overridable by system
environment variables
https://github.com/steinarb/sonar-collector/blob/master/docker/docker/org.ops4j.datasource-sonar-collector.cfg#L2
This image will provision itself from maven central (sonar-collector is
released to maven-central) and will always use the latest released
version, so there is no need to build a new docker image if a new
version of sonar-collector is released to maven central.
Since the database schema is set up by liquibase and the SQL used is
trivial (inserts rows into a single table), it should in theory be
possible to use a different database than PostgreSQL, and I have
provided the possibility to override the database used when doing
"docker run" of the image.
But using other databases than PostgreSQL is something I haven't
extensively tested.
|