From 6e9fc8d699d839ce174c2e859b8f14b8948835e0 Mon Sep 17 00:00:00 2001 From: David DE CARVALHO Date: Sun, 21 Jul 2024 16:22:20 +0200 Subject: [PATCH] upgrade docker system --- CHANGELOG.md | 2 ++ Dockerfile | 11 +++++++++-- docker-compose.yml | 21 +++++++++++++++------ 3 files changed, 26 insertions(+), 8 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 14cfcbd..5df6054 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,6 +11,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Changed +- refactoring docker system + ### Deleted ## [1.4.4] - 2024-07-18 diff --git a/Dockerfile b/Dockerfile index bec96c2..9e6d105 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,9 +1,16 @@ -FROM maven:3-openjdk-11-slim AS builder +ARG MAVEN_BUILDER=3-openjdk-17-slim +ARG SONARQUBE_VERSION=10.4.1-community + +FROM maven:${MAVEN_BUILDER} AS builder COPY . /usr/src/ecocode WORKDIR /usr/src/ecocode +COPY src src/ +COPY pom.xml tool_build.sh ./ + RUN ./tool_build.sh -FROM sonarqube:10.4.1-community +FROM sonarqube:${SONARQUBE_VERSION} COPY --from=builder /usr/src/ecocode/target/ecocode-*.jar /opt/sonarqube/extensions/plugins/ +USER sonarqube diff --git a/docker-compose.yml b/docker-compose.yml index 28ecdbb..c68bb3a 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,23 +1,27 @@ -version: "3.3" +name: sonarqube_ecocode_python + services: sonar: - image: sonarqube:10.4.1-community + build: . container_name: sonar_ecocode_python ports: - ":9000" networks: - sonarnet depends_on: - - db + db: + condition: service_healthy environment: SONAR_JDBC_USERNAME: sonar SONAR_JDBC_PASSWORD: sonar SONAR_JDBC_URL: jdbc:postgresql://db:5432/sonarqube SONAR_ES_BOOTSTRAP_CHECKS_DISABLE: 'true' + env_file: + - path: ./.default.docker.env + required: true + - path: ./.override.docker.env + required: false volumes: - - type: bind - source: ./target/ecocode-python-plugin-1.4.5-SNAPSHOT.jar - target: /opt/sonarqube/extensions/plugins/ecocode-python-plugin-1.4.5-SNAPSHOT.jar - "extensions:/opt/sonarqube/extensions" - "logs:/opt/sonarqube/logs" - "data:/opt/sonarqube/data" @@ -34,6 +38,11 @@ services: POSTGRES_PASSWORD: sonar POSTGRES_DB: sonarqube PGDATA: pg_data:/var/lib/postgresql/data/pgdata + healthcheck: + test: [ "CMD-SHELL", "pg_isready -U sonar -d sonarqube" ] + interval: 5s + timeout: 5s + retries: 5 networks: sonarnet: