diff --git a/charts/nebulous-resource-manager/values.yaml b/charts/nebulous-resource-manager/values.yaml index 076f2f4..b701012 100644 --- a/charts/nebulous-resource-manager/values.yaml +++ b/charts/nebulous-resource-manager/values.yaml @@ -5,7 +5,7 @@ replicaCount: 1 image: - repository: "quay.io/nebulous/resource-manager-java-spring-boot-demo" + repository: "quay.io/nebulous/resource-manager" pullPolicy: IfNotPresent # Overrides the image tag whose default is the chart appVersion. tag: "" diff --git a/resource-discovery/.dockerignore b/resource-discovery/.dockerignore new file mode 100644 index 0000000..2f7896d --- /dev/null +++ b/resource-discovery/.dockerignore @@ -0,0 +1 @@ +target/ diff --git a/resource-discovery/Dockerfile b/resource-discovery/Dockerfile new file mode 100644 index 0000000..7f2a763 --- /dev/null +++ b/resource-discovery/Dockerfile @@ -0,0 +1,48 @@ + +ARG BUILDER_IMAGE=docker.io/library/maven:3.9.5-eclipse-temurin-17 +ARG RUN_IMAGE=docker.io/library/eclipse-temurin:17.0.8.1_1-jre + +# ----------------- Builder image ----------------- +FROM docker.io/library/maven:3.9.5-eclipse-temurin-17 as rd-builder +ENV BASEDIR /app +WORKDIR ${BASEDIR} +COPY src ${BASEDIR}/src +COPY pom.xml ${BASEDIR}/ +COPY run.sh ${BASEDIR}/ +RUN mvn -f ${BASEDIR}/pom.xml -DskipTests clean install && \ + java -Djarmode=layertools -jar ${BASEDIR}/target/resource-discovery-*.jar extract + +# ----------------- Runtime image ----------------- +FROM docker.io/library/eclipse-temurin:17.0.8.1_1-jre + +# Setup environment +ENV BASEDIR /opt/resource-discovery +ENV RD_HOME ${BASEDIR} + +# Install required and optional packages +RUN wget --progress=dot:giga -O /usr/local/bin/dumb-init \ + https://github.com/Yelp/dumb-init/releases/download/v1.2.5/dumb-init_1.2.5_x86_64 && \ + chmod +x /usr/local/bin/dumb-init + +# Add RD user +ARG RD_USER=rd +RUN mkdir ${RD_HOME} ; \ + addgroup ${RD_USER} ; \ + adduser --home ${RD_HOME} --no-create-home --ingroup ${RD_USER} --disabled-password ${RD_USER} ; \ + chown ${RD_USER}:${RD_USER} ${RD_HOME} + +# Set User and Workdir +USER ${RD_USER} +WORKDIR ${BASEDIR} + +# Copy files from builder container +COPY --chown=${RD_USER}:${RD_USER} --from=rd-builder /app/dependencies ${BASEDIR} +COPY --chown=${RD_USER}:${RD_USER} --from=rd-builder /app/spring-boot-loader ${BASEDIR} +COPY --chown=${RD_USER}:${RD_USER} --from=rd-builder /app/snapshot-dependencies ${BASEDIR} +COPY --chown=${RD_USER}:${RD_USER} --from=rd-builder /app/application ${BASEDIR} +COPY --chown=${RD_USER}:${RD_USER} --from=rd-builder /app/run.sh ${BASEDIR} +RUN chmod +x run.sh + +EXPOSE 8080 + +ENTRYPOINT ["dumb-init", "./run.sh"] \ No newline at end of file diff --git a/resource-discovery/pom.xml b/resource-discovery/pom.xml index 01a052d..bf395bb 100644 --- a/resource-discovery/pom.xml +++ b/resource-discovery/pom.xml @@ -85,6 +85,16 @@ + + + org.springframework.boot + spring-boot-maven-plugin + + + + + + diff --git a/resource-discovery/run.sh b/resource-discovery/run.sh new file mode 100644 index 0000000..1dc69b8 --- /dev/null +++ b/resource-discovery/run.sh @@ -0,0 +1,55 @@ +#!/usr/bin/env bash + +# Change directory to RD home +PREVWORKDIR=`pwd` +BASEDIR=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd ) +cd ${BASEDIR} + +# Read JASYPT password (decrypts encrypted configuration settings) +#if [[ -z "$JASYPT_PASSWORD" ]]; then +# printf "Configuration Password: " +# read -s JASYPT_PASSWORD +# export JASYPT_PASSWORD +#fi +# Use this online service to encrypt/decrypt passwords: +# https://www.devglan.com/online-tools/jasypt-online-encryption-decryption + + +# Setup TERM & INT signal handler +trap 'echo "Signaling server to exit"; kill -TERM "${pid}"; wait "${pid}"; ' SIGTERM SIGINT + +# Set JRE command and options +JRE=/opt/java/openjdk/bin/java +#JAVA_ADD_OPENS="--add-opens java.base/java.lang=ALL-UNNAMED --add-opens java.base/java.util.regex=ALL-UNNAMED --add-opens java.base/sun.nio.cs=ALL-UNNAMED --add-opens java.base/java.nio.charset=ALL-UNNAMED" + +# Set shell encoding to UTF-8 (in order to display banner correctly) +export LANG=C.UTF-8 + +# Print basic env. info +echo "--------------------------------------------------------------------------------" +echo "Env. info:" +echo "LANG: ${LANG}" +echo "USER: $( whoami )" +echo "IP address: `hostname -I`" +echo "--------------------------------------------------------------------------------" +echo "JRE:" +${JRE} -version +echo "--------------------------------------------------------------------------------" +echo "Starting Resource Discovery server..." + +# Run RD server +${JRE} \ + $JAVA_OPTS \ + $JAVA_ADD_OPENS \ + -Djasypt.encryptor.password=$JASYPT_PASSWORD \ + -Djava.security.egd=file:/dev/urandom \ + org.springframework.boot.loader.JarLauncher \ + $* & + +# Get PID and wait it to exit +pid=$! +echo "Pid: $pid" +wait $pid +echo "Server exited" + +cd $PREVWORKDIR diff --git a/zuul.d/jobs.yaml b/zuul.d/jobs.yaml index e5ca427..e934cf1 100644 --- a/zuul.d/jobs.yaml +++ b/zuul.d/jobs.yaml @@ -8,15 +8,15 @@ - nebulous-resource-manager-container-images description: Build the container images. files: &image_files - - ^java-spring-boot-demo/ + - ^resource-discovery/ vars: &image_vars promote_container_image_job: nebulous-resource-manager-upload-container-images container_images: - - context: java-spring-boot-demo + - context: resource-discovery registry: quay.io - repository: quay.io/nebulous/resource-manager-java-spring-boot-demo + repository: quay.io/nebulous/resource-manager namespace: nebulous - repo_shortname: resource-manager-java-spring-boot-demo + repo_shortname: resource-manager repo_description: "" - job: @@ -44,7 +44,7 @@ description: Run Hadolint on Dockerfile(s). vars: dockerfiles: - - java-spring-boot-demo/Dockerfile + - resource-discovery/Dockerfile - job: name: nebulous-resource-manager-helm-lint