From user-return-22142-apmail-karaf-user-archive=karaf.apache.org@karaf.apache.org Tue Apr 21 16:47:18 2020 Return-Path: X-Original-To: apmail-karaf-user-archive@minotaur.apache.org Delivered-To: apmail-karaf-user-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [207.244.88.153]) by minotaur.apache.org (Postfix) with SMTP id 4DE7A19F91 for ; Tue, 21 Apr 2020 16:47:18 +0000 (UTC) Received: (qmail 4787 invoked by uid 500); 21 Apr 2020 16:47:17 -0000 Delivered-To: apmail-karaf-user-archive@karaf.apache.org Received: (qmail 4749 invoked by uid 500); 21 Apr 2020 16:47:16 -0000 Mailing-List: contact user-help@karaf.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: user@karaf.apache.org Delivered-To: mailing list user@karaf.apache.org Received: (qmail 4728 invoked by uid 99); 21 Apr 2020 16:47:16 -0000 Received: from pnap-us-west-generic-nat.apache.org (HELO spamd4-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 21 Apr 2020 16:47:16 +0000 Received: from localhost (localhost [127.0.0.1]) by spamd4-us-west.apache.org (ASF Mail Server at spamd4-us-west.apache.org) with ESMTP id 1F3E8C1DDE for ; Tue, 21 Apr 2020 16:47:16 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd4-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: 0.26 X-Spam-Level: X-Spam-Status: No, score=0.26 tagged_above=-999 required=6.31 tests=[HEADER_FROM_DIFFERENT_DOMAINS=0.25, KAM_DMARC_STATUS=0.01, SPF_HELO_NONE=0.001, SPF_PASS=-0.001] autolearn=disabled Received: from mx1-he-de.apache.org ([10.40.0.8]) by localhost (spamd4-us-west.apache.org [10.40.0.11]) (amavisd-new, port 10024) with ESMTP id cJ8sg9ASbfzj for ; Tue, 21 Apr 2020 16:47:14 +0000 (UTC) Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=159.69.161.202; helo=ciao.gmane.io; envelope-from=gcaku-user@m.gmane-mx.org; receiver= Received: from ciao.gmane.io (ciao.gmane.io [159.69.161.202]) by mx1-he-de.apache.org (ASF Mail Server at mx1-he-de.apache.org) with ESMTPS id 224227FBC6 for ; Tue, 21 Apr 2020 16:36:41 +0000 (UTC) Received: from list by ciao.gmane.io with local (Exim 4.92) (envelope-from ) id 1jQvsw-000Mkp-Es for user@karaf.apache.org; Tue, 21 Apr 2020 18:36:34 +0200 X-Injected-Via-Gmane: http://gmane.org/ Mail-Followup-To: user@karaf.apache.org To: user@karaf.apache.org From: Steinar Bang Subject: My first real karaf-based docker image: sonar-collector Date: Tue, 21 Apr 2020 18:36:26 +0200 Organization: Probably a good idea Message-ID: <864ktcpzhx.fsf_-_@dod.no> References: <86371jjydh.fsf@dod.no> <86o8rwkf9z.fsf_-_@dod.no> <86eessjzeg.fsf@dod.no> <865ze3kehk.fsf@dod.no> <86wo6ji4o0.fsf@dod.no> Mime-Version: 1.0 Content-Type: text/plain User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.3 (windows-nt) Cancel-Lock: sha1:U4gAEiGm+GGM5JbMSzIfTbgONXM= Mail-Copies-To: never 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.