Skip to content

Commit

Permalink
Upgrade JVM environment (#382)
Browse files Browse the repository at this point in the history
* OpenJDK8 used by jvm environment is deprecated.
Now, JVM environment uses OpenJDK22 built by Eclipse Temurin.
Updated springframework version to 3.3.2.

Signed-off-by: Md Soharab Ansari <[email protected]>

* Update helm and K8s version for jvm workflow

Signed-off-by: Md Soharab Ansari <[email protected]>

* Update fission-cli and skaffold version for jvm workflow

Signed-off-by: Md Soharab Ansari <[email protected]>

* Optimize Dockerfile for jvm-builder

Signed-off-by: Md Soharab Ansari <[email protected]>

* Fix JVM environment workflow

Signed-off-by: Md Soharab Ansari <[email protected]>

* Fix JVM environment tests

Signed-off-by: Md Soharab Ansari <[email protected]>

---------

Signed-off-by: Md Soharab Ansari <[email protected]>
  • Loading branch information
soharab-ic authored Sep 4, 2024
1 parent e69bb96 commit a9d613e
Show file tree
Hide file tree
Showing 10 changed files with 47 additions and 61 deletions.
29 changes: 14 additions & 15 deletions .github/workflows/environment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -118,34 +118,33 @@ jobs:
with:
filters: .github/workflows/filters/filters.yaml
- name: Helm
uses: Azure/setup-helm@v1
uses: Azure/setup-helm@5119fcb9089d432beecbf79bb2c7915207344b78 # v3.5
with:
version: 'v3.0.0'
version: v3.13.0
- name: Kind Clutser
uses: engineerd/[email protected]
with:
image: kindest/node:v1.21.1
version: v0.11.1
image: kindest/node:v1.25.16
version: v0.23.0
config: kind.yaml
- name: Configuring and testing the Installation
run: |
kubectl cluster-info --context kind-kind
kind get kubeconfig >$HOME/.kube/config
kubectl get nodes
- name: Install Fission CLI
- name: Base Setup
run: |
curl -Lo fission https://github.com/fission/fission/releases/download/1.12.0/fission-cli-linux \
&& chmod +x fission && sudo mv fission /usr/local/bin/
make verify-kind-cluster
make install-fission-cli
make install-skaffold
make create-crds
- name: jvm
uses: hiberbee/[email protected]
with:
skaffold-version: '1.39.2'
command: run
profile: jvm
tag: latest
- name: jvm-tests
run: |
kind load docker-image jvm-env && ./test_utils/run_test.sh jvm/tests/test_java_env.sh
SKAFFOLD_PROFILE=jvm make skaffold-run
make jvm-test-images
make router-port-forward
- name: jvm-tests
run: ./test_utils/run_test.sh jvm/tests/test_java_env.sh
nodejs:
runs-on: ubuntu-latest
needs: check
Expand Down
4 changes: 4 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,10 @@ go-test-images:
@kind load docker-image go-env
@kind load docker-image go-builder

jvm-test-images:
@kind load docker-image jvm-env
@kind load docker-image jvm-builder

nodejs-test-images:
@kind load docker-image node-env
@kind load docker-image node-builder
Expand Down
6 changes: 3 additions & 3 deletions jvm/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM maven:3.5-jdk-8 as BUILD
FROM maven:3.9.9-eclipse-temurin-22-alpine AS build
WORKDIR /usr/src/myapp/

# To reuse the build cache, here we split maven dependency
Expand All @@ -9,8 +9,8 @@ RUN mvn dependency:go-offline
COPY src /usr/src/myapp/src/
RUN mvn package

FROM openjdk:8-jdk-alpine
FROM eclipse-temurin:22-jdk-alpine
VOLUME /tmp
COPY --from=BUILD /usr/src/myapp/target/env-java-0.0.1-SNAPSHOT.jar /app.jar
COPY --from=build /usr/src/myapp/target/env-java-0.0.1-SNAPSHOT.jar /app.jar
ENTRYPOINT java ${JVM_OPTS} -Djava.security.egd=file:/dev/./urandom -jar /app.jar --server.port=8888
EXPOSE 8888
2 changes: 1 addition & 1 deletion jvm/Makefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
-include ../rules.mk

.PHONY: all
all: jvm-builder jvm-env-img
all: jvm-env-img

jvm-env-img: Dockerfile
4 changes: 2 additions & 2 deletions jvm/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

This is the JVM environment for Fission.

It's a Docker image containing a OpenJDK8 runtime, along with a
It's a Docker image containing a OpenJDK22 runtime by [Eclipse Temurin](https://hub.docker.com/_/eclipse-temurin), along with a
dynamic loader. A few dependencies are included in the
pom.xml file.

Expand Down Expand Up @@ -67,4 +67,4 @@ JVM environment uses Tomcat HTTP server by default as it is included in spring w

## Java and JVM builder

JVM environment builder is based on OpenJDK8 and Maven 3.5.4 version. The default build command runs `mvn clean package` and uses the target/*with-dependencies.jar file for function. The default build command can be overridden as long as the uber jar file is copied to ${DEPLOY_PKG}.
JVM environment builder is based on OpenJDK22 built by Eclipse Temurin and Maven 3.9.9 version. The default build command runs `mvn clean package` and uses the target/*with-dependencies.jar file for function. The default build command can be overridden as long as the uber jar file is copied to ${DEPLOY_PKG}.
53 changes: 18 additions & 35 deletions jvm/builder/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,50 +1,33 @@
## Fission builder base image
ARG BUILDER_IMAGE=fission/builder:latest
FROM ${BUILDER_IMAGE}
FROM ${BUILDER_IMAGE} AS builder

## Section copied from the openjdk:8-jdk-alpine Dockerfile - (https://github.com/docker-library/openjdk/blob/47a6539cd18023dafb45db9013455136cc0bca07/8/jdk/alpine/Dockerfile)
## Use eclipse-temurin:22-jdk-alpine - (https://github.com/adoptium/containers/blob/07677395574f5d3462c3b6fdf5f6c4a0a350b683/22/jdk/alpine/Dockerfile)

FROM alpine:3.8
FROM eclipse-temurin:22-jdk-alpine

ENV LANG C.UTF-8
RUN { \
echo '#!/bin/sh'; \
echo 'set -e'; \
echo; \
echo 'dirname "$(dirname "$(readlink -f "$(which javac || which java)")")"'; \
} > /usr/local/bin/docker-java-home \
&& chmod +x /usr/local/bin/docker-java-home
ENV JAVA_HOME /usr/lib/jvm/java-1.8-openjdk
ENV PATH $PATH:/usr/lib/jvm/java-1.8-openjdk/jre/bin:/usr/lib/jvm/java-1.8-openjdk/bin
## Section copied from the Maven Dockerfile

ENV JAVA_VERSION 8u181
## Use "fuzzy" version matching to pin the version to a major/minor release
ENV JAVA_ALPINE_VERSION "~8"
RUN apk add --no-cache bash procps curl tar openssh-client

RUN set -x \
&& apk add --no-cache \
openjdk8="$JAVA_ALPINE_VERSION" \
&& [ "$JAVA_HOME" = "$(docker-java-home)" ]
LABEL org.opencontainers.image.title="Apache Maven"
LABEL org.opencontainers.image.source=https://github.com/carlossg/docker-maven
LABEL org.opencontainers.image.url=https://github.com/carlossg/docker-maven
LABEL org.opencontainers.image.description="Apache Maven is a software project management and comprehension tool. Based on the concept of a project object model (POM), Maven can manage a project's build, reporting and documentation from a central piece of information."

## Section copied from the Maven Dockerfile
ENV MAVEN_HOME=/usr/share/maven

RUN apk add --no-cache curl tar bash procps
COPY --from=maven:3.9.9-eclipse-temurin-11 ${MAVEN_HOME} ${MAVEN_HOME}
COPY --from=maven:3.9.9-eclipse-temurin-11 /usr/local/bin/mvn-entrypoint.sh /usr/local/bin/mvn-entrypoint.sh
COPY --from=maven:3.9.9-eclipse-temurin-11 /usr/share/maven/ref/settings-docker.xml /usr/share/maven/ref/settings-docker.xml

ARG MAVEN_VERSION=3.5.4
ARG USER_HOME_DIR="/root"
ARG SHA=ce50b1c91364cb77efe3776f756a6d92b76d9038b0a0782f7d53acf1e997a14d
ARG BASE_URL=https://apache.osuosl.org/maven/maven-3/${MAVEN_VERSION}/binaries
RUN ln -s ${MAVEN_HOME}/bin/mvn /usr/bin/mvn

RUN mkdir -p /usr/share/maven /usr/share/maven/ref \
&& curl -fsSL -o /tmp/apache-maven.tar.gz ${BASE_URL}/apache-maven-${MAVEN_VERSION}-bin.tar.gz \
&& echo "${SHA} /tmp/apache-maven.tar.gz" | sha256sum -c - \
&& tar -xzf /tmp/apache-maven.tar.gz -C /usr/share/maven --strip-components=1 \
&& rm -f /tmp/apache-maven.tar.gz \
&& ln -s /usr/share/maven/bin/mvn /usr/bin/mvn

ENV MAVEN_HOME /usr/share/maven
ENV MAVEN_CONFIG "$USER_HOME_DIR/.m2"
ARG MAVEN_VERSION=3.9.9
ARG USER_HOME_DIR="/root"
ENV MAVEN_CONFIG="$USER_HOME_DIR/.m2"

## Fission builder specific section
COPY --from=builder /builder /builder
ADD build.sh /usr/local/bin/build
EXPOSE 8001
2 changes: 1 addition & 1 deletion jvm/builder/Makefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
-include ../../rules.mk

.PHONY: all
all: jvm-env-builder-img
all: jvm-builder-img

jvm-builder-img : Dockerfile
4 changes: 2 additions & 2 deletions jvm/envconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@
],
"name": "JVM Environment",
"readme": "https://github.com/fission/environments/tree/master/jvm",
"runtimeVersion": "8",
"runtimeVersion": "22",
"shortDescription": "JVM environment based on Spring Boot server",
"status": "Stable",
"version": "1.31.1"
"version": "1.31.2"
}
]
2 changes: 1 addition & 1 deletion jvm/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.0.1.RELEASE</version>
<version>3.3.2</version>
</parent>

<dependencies>
Expand Down
2 changes: 1 addition & 1 deletion jvm/tests/test_java_env.sh
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ cd jvm/examples/java

log "Creating the jar from application"
#Using Docker to build Jar so that maven & other Java dependencies are not needed on CI server
docker run -it --rm -v "$(pwd)":/usr/src/mymaven -w /usr/src/mymaven maven:3.5-jdk-8 mvn clean package -q
docker run --rm -v "$(pwd)":/usr/src/mymaven -w /usr/src/mymaven maven:3.9.9-eclipse-temurin-22-alpine mvn clean package -q

log "Creating environment for Java"
fission env create --name $env --image $JVM_RUNTIME_IMAGE --version 2 --keeparchive=true
Expand Down

0 comments on commit a9d613e

Please sign in to comment.