Use the right container image

* Updated Zuul and Helm files with the right settings
* Cleared Buildpacks settings, and added Dockerfile

Change-Id: I35fc05e34fad405e0981f822e39139d7d244252e
This commit is contained in:
ipatini 2023-10-31 11:22:19 +02:00 committed by Radosław Piliszek
parent 0c05760636
commit 2cf4d6a7f9
6 changed files with 121 additions and 7 deletions

View File

@ -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: ""

View File

@ -0,0 +1 @@
target/

View File

@ -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"]

View File

@ -85,6 +85,16 @@
</dependencyManagement>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
<!-- Creating Docker image with BUILDPACKS -->
<!--<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
@ -106,6 +116,6 @@
</configuration>
</plugin>
</plugins>
</build>
</build>-->
</project>

55
resource-discovery/run.sh Normal file
View File

@ -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

View File

@ -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