Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#13779: Decouple docker from maven #30

Merged
merged 13 commits into from
Nov 15, 2024
Merged
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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like you're using this for sane defaults?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, it's used for defaults only.

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
ademarcqrtsl marked this conversation as resolved.
Show resolved Hide resolved

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
Loading