Skip to content

Commit

Permalink
#13779: Decouple docker from maven (#30)
Browse files Browse the repository at this point in the history
* Refactors docker_build to be autonomousé

* Removes docker build from maven main pom

* Modifies build to build images independently

* Fixes path error

* Docker file cleaning

* Refactors docker_build to be autonomousé

* Removes docker build from maven main pom

* Modifies build to build images independently

* Fixes path error

* Docker file cleaning

* redundant files cleaning

* Fixes version in docker_run

---------

Co-authored-by: Arnaud DEMARCQ <[email protected]>
  • Loading branch information
ademarcqrtsl and Arnaud DEMARCQ authored Nov 15, 2024
1 parent 04c841e commit b153434
Show file tree
Hide file tree
Showing 10 changed files with 32 additions and 189 deletions.
11 changes: 7 additions & 4 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,18 +24,21 @@ jobs:
- uses: stCarolas/[email protected]
with:
maven-version: 3.9.6
- name: docker-compose workaround
run: echo "docker compose \"\$@\"" > $HOME/docker-compose ; chmod 777 $HOME/docker-compose ; echo "$HOME/" >> $GITHUB_PATH
- name: Clean branch name
- name: Set Environment Variables
run: |
BRANCH_NAME=${{ github.ref_name }}
CLEAN_BRANCH_NAME=$(echo $BRANCH_NAME | sed 's/[\/_]/-/g')
echo "Cleaned branch name: $CLEAN_BRANCH_NAME"
echo CLEAN_BRANCH_NAME=$CLEAN_BRANCH_NAME >> $GITHUB_ENV
- name: Sets up version
run: mvn versions:set -DnewVersion=${{ env.CLEAN_BRANCH_NAME }}.${{github.run_number}}
- name: Builds Artifacts and Images
- name: Builds Artifacts
run: mvn clean install
- name: Builds Images
working-directory: ./docker_build
run: |
export PROJECT_VERSION=${{ env.CLEAN_BRANCH_NAME }}.${{github.run_number}}
docker compose build
- name: Publish Images
run: docker push simpledotorg/prometheusdbexporter:${{ env.CLEAN_BRANCH_NAME }}.${{github.run_number}}
- name: Archive Dhis2TestTool jar file
Expand Down
1 change: 1 addition & 0 deletions docker_build/.env
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
PROJECT_VERSION=0.0.0
9 changes: 5 additions & 4 deletions docker_build/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
services:
prometheusdbexporter:
image: simpledotorg/prometheusdbexporter:${PROJECT_VERSION}
build:
context: .
dockerfile: prometheus.db.exporter.docker
image: simpledotorg/prometheusdbexporter:${project.version}

context: ..
dockerfile: ./docker_build/prometheus.db.exporter.docker
args:
PROJECT_VERSION: ${PROJECT_VERSION}
85 changes: 0 additions & 85 deletions docker_build/pom.xml

This file was deleted.

24 changes: 18 additions & 6 deletions docker_build/prometheus.db.exporter.docker
Original file line number Diff line number Diff line change
@@ -1,11 +1,23 @@
from tomcat:11.0-jdk21

ENV JAVA_OPTS " -Dlogback.ContextSelector=JNDI "
ARG PROJECT_VERSION

COPY ./PrometheusDatabaseExporterWar-${project.version}.war /app/rtsl/prom_db_exporter/
COPY ./prometheus_db_exporter/*.properties /app/rtsl/prom_db_exporter/
COPY ./prometheus_db_exporter/logback.xml /app/rtsl/prom_db_exporter/
#
# Files and Folders
#
COPY ./Webapps/PrometheusDatabaseExporterWar/target/PrometheusDatabaseExporterWar-*.war /app/rtsl/prom_db_exporter/
COPY ./docker_content/prometheus_db_exporter/*.properties /app/rtsl/prom_db_exporter/
COPY ./docker_content/prometheus_db_exporter/logback.xml /app/rtsl/prom_db_exporter/
COPY ./docker_content/prometheus_db_exporter/PrometheusDbExporter.xml /usr/local/tomcat/conf/Catalina/localhost/
RUN mkdir /app/rtsl/prom_db_exporter/sources

COPY ./prometheus_db_exporter/PrometheusDbExporter.xml /usr/local/tomcat/conf/Catalina/localhost/
#
# System needs to be as up to date as possible
#
#RUN apt-get update ; apt-get upgrade ; apt-get clean

ENV JAVA_OPTS " -Dlogback.ContextSelector=JNDI "

## Templates the config files based on the ARGS
RUN sed -i "s/\${project.version}/${PROJECT_VERSION}/g" /usr/local/tomcat/conf/Catalina/localhost/PrometheusDbExporter.xml

RUN mkdir /app/rtsl/prom_db_exporter/sources
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
database.jdbc.url=jdbc:postgresql://host.docker.internal:5432/dhis?ApplicationName=PrometheusDatabaseExporterWar
database.jdbc.url=jdbc:postgresql://database:5432/dhis?ApplicationName=PrometheusDatabaseExporterWar

config.root.folder=/app/rtsl/prom_db_exporter/sources
cache.folder=/tmp/prom_db_exporter_cache/
19 changes: 0 additions & 19 deletions packager/assembly.docker_build.xml

This file was deleted.

19 changes: 0 additions & 19 deletions packager/assembly.docker_content.xml

This file was deleted.

49 changes: 0 additions & 49 deletions packager/pom.xml

This file was deleted.

2 changes: 0 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@
<module>Helpers</module>
<module>CommonUtils</module>
<module>Webapps</module>
<module>packager</module>
<module>docker_build</module>
</modules>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
Expand Down

0 comments on commit b153434

Please sign in to comment.