From 09ab082f14d0c5476d449a8e49d92c023b3398ee Mon Sep 17 00:00:00 2001 From: amandilaras Date: Fri, 22 Dec 2023 15:22:39 +0200 Subject: [PATCH] add Dockerfile for sonar analysis --- Dockerfile.Sonar | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 Dockerfile.Sonar diff --git a/Dockerfile.Sonar b/Dockerfile.Sonar new file mode 100644 index 0000000..9fa4bef --- /dev/null +++ b/Dockerfile.Sonar @@ -0,0 +1,37 @@ +FROM maven:3-eclipse-temurin-21 + +RUN apt-get update \ + && apt-get install gpg -y \ + && apt-get clean + +ARG MAVEN_ACCOUNT_USR +ARG MAVEN_ACCOUNT_PSW +ARG REVISION +ARG MAVEN_GPG_PASSPHRASE +ARG MAVEN_GPG_KEYNAME +ARG PROFILE +ARG DEV_PROFILE_URL_DEPOSIT +ARG DEV_PROFILE_URL +ARG ORACLE_URL +ARG ORACLE_TOKEN +ENV gpg_keyname=$MAVEN_GPG_KEYNAME +ENV gpg_passphrase=$MAVEN_GPG_PASSPHRASE +ENV server_username=$MAVEN_ACCOUNT_USR +ENV server_password=$MAVEN_ACCOUNT_PSW + +COPY settings.xml /root/.m2/settings.xml +COPY keypair.asc /tmp/keypair.asc +RUN if [ "$PROFILE" = "ossrh" ]; then \ + gpg --batch --import /tmp/keypair.asc; \ + fi + +COPY oracle.local.cite.gr.crt $JAVA_HOME/conf/security +RUN cd $JAVA_HOME/conf/security && keytool -cacerts -storepass changeit -noprompt -trustcacerts -importcert -alias oraclecert -file oracle.local.cite.gr.crt + +WORKDIR /build/ + +COPY . . + +RUN mvn -Drevision=${REVISION} -DdevProfileUrlDeposit=${DEV_PROFILE_URL_DEPOSIT} -DdevProfileUrl=${DEV_PROFILE_URL} -P${PROFILE} clean deploy + +RUN mvn sonar:sonar -Dsonar.projectKey=OpenDMP:repository-deposit-base -Dsonar.login=${ORACLE_TOKEN} -Dsonar.host.url=${ORACLE_URL} -Dsonar.projectName='OpenDMP repository-deposit-base' \ No newline at end of file