Skip to content

Commit

Permalink
Merge pull request educates#266 from GrahamDumpleton/jdk21-environmen…
Browse files Browse the repository at this point in the history
…t-image

Add JDK 21 workshop base image.
  • Loading branch information
GrahamDumpleton authored Jan 16, 2024
2 parents 03f3830 + 06cac25 commit 4c6985a
Show file tree
Hide file tree
Showing 18 changed files with 154 additions and 18 deletions.
1 change: 1 addition & 0 deletions .github/workflows/build-and-publish-images.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -328,6 +328,7 @@ jobs:
- image: jdk8-environment
- image: jdk11-environment
- image: jdk17-environment
- image: jdk21-environment
- image: conda-environment

steps:
Expand Down
12 changes: 10 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,15 @@ all: push-all-images deploy-cluster-essentials deploy-training-platform deploy-w

build-all-images: build-session-manager build-training-portal \
build-base-environment build-jdk8-environment build-jdk11-environment \
build-jdk17-environment build-conda-environment build-docker-registry \
build-jdk17-environment build-jdk21-environment \
build-conda-environment build-docker-registry \
build-pause-container build-secrets-manager build-tunnel-manager \
build-image-cache build-assets-server

push-all-images: push-session-manager push-training-portal \
push-base-environment push-jdk8-environment push-jdk11-environment \
push-jdk17-environment push-conda-environment push-docker-registry \
push-jdk17-environment push-jdk21-environment \
push-conda-environment push-docker-registry \
push-pause-container push-secrets-manager push-tunnel-manager \
push-image-cache push-assets-server

Expand Down Expand Up @@ -77,6 +79,12 @@ build-jdk17-environment: build-base-environment
push-jdk17-environment: build-jdk17-environment
docker push $(IMAGE_REPOSITORY)/educates-jdk17-environment:$(PACKAGE_VERSION)

build-jdk21-environment: build-base-environment
docker build --progress plain --platform $(DOCKER_PLATFORM) --build-arg PACKAGE_VERSION=$(PACKAGE_VERSION) -t $(IMAGE_REPOSITORY)/educates-jdk21-environment:$(PACKAGE_VERSION) workshop-images/jdk21-environment

push-jdk21-environment: build-jdk21-environment
docker push $(IMAGE_REPOSITORY)/educates-jdk21-environment:$(PACKAGE_VERSION)

build-conda-environment: build-base-environment
docker build --progress plain --platform $(DOCKER_PLATFORM) --build-arg PACKAGE_VERSION=$(PACKAGE_VERSION) -t $(IMAGE_REPOSITORY)/educates-conda-environment:$(PACKAGE_VERSION) workshop-images/conda-environment

Expand Down
2 changes: 2 additions & 0 deletions carvel-packages/training-platform/config/images.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ imageVersions:
image: #@ image_reference("jdk11-environment")
- name: jdk17-environment
image: #@ image_reference("jdk17-environment")
- name: jdk21-environment
image: #@ image_reference("jdk21-environment")
- name: conda-environment
image: #@ image_reference("conda-environment")
- name: secrets-manager
Expand Down
2 changes: 2 additions & 0 deletions client-programs/pkg/cmd/docker_workshop_deploy_cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -761,12 +761,14 @@ func generateWorkshopImageName(workshop *unstructured.Unstructured, localReposit
image = strings.ReplaceAll(image, "jdk8-environment:*", fmt.Sprintf("localhost:5001/educates-jdk8-environment:%s", defaultImageVersion))
image = strings.ReplaceAll(image, "jdk11-environment:*", fmt.Sprintf("localhost:5001/educates-jdk11-environment:%s", defaultImageVersion))
image = strings.ReplaceAll(image, "jdk17-environment:*", fmt.Sprintf("localhost:5001/educates-jdk17-environment:%s", defaultImageVersion))
image = strings.ReplaceAll(image, "jdk21-environment:*", fmt.Sprintf("localhost:5001/educates-jdk21-environment:%s", defaultImageVersion))
image = strings.ReplaceAll(image, "conda-environment:*", fmt.Sprintf("localhost:5001/educates-conda-environment:%s", defaultImageVersion))
} else {
image = strings.ReplaceAll(image, "base-environment:*", fmt.Sprintf("%s/educates-base-environment:%s", imageRepository, defaultImageVersion))
image = strings.ReplaceAll(image, "jdk8-environment:*", fmt.Sprintf("%s/educates-jdk8-environment:%s", imageRepository, defaultImageVersion))
image = strings.ReplaceAll(image, "jdk11-environment:*", fmt.Sprintf("%s/educates-jdk11-environment:%s", imageRepository, defaultImageVersion))
image = strings.ReplaceAll(image, "jdk17-environment:*", fmt.Sprintf("%s/educates-jdk17-environment:%s", imageRepository, defaultImageVersion))
image = strings.ReplaceAll(image, "jdk21-environment:*", fmt.Sprintf("%s/educates-jdk21-environment:%s", imageRepository, defaultImageVersion))
image = strings.ReplaceAll(image, "conda-environment:*", fmt.Sprintf("%s/educates-conda-environment:%s", imageRepository, defaultImageVersion))
}
}
Expand Down
1 change: 1 addition & 0 deletions developer-docs/build-instructions.md
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,7 @@ make push-base-environment
make push-jdk8-environment
make push-jdk11-environment
make push-jdk17-environment
make push-jdk21-environment
make push-conda-environment
```

Expand Down
1 change: 1 addition & 0 deletions project-docs/custom-resources/workshop-definition.md
Original file line number Diff line number Diff line change
Expand Up @@ -477,6 +477,7 @@ The short versions of the names which are recognised are:
* ``jdk8-environment:*`` - A tagged version of the ``jdk8-environment`` workshop image which has been matched with the current version of the Educates operator.
* ``jdk11-environment:*`` - A tagged version of the ``jdk11-environment`` workshop image which has been matched with the current version of the Educates operator.
* ``jdk17-environment:*`` - A tagged version of the ``jdk17-environment`` workshop image which has been matched with the current version of the Educates operator.
* ``jdk21-environment:*`` - A tagged version of the ``jdk121-environment`` workshop image which has been matched with the current version of the Educates operator.
* ``conda-environment:*`` - A tagged version of the ``conda-environment`` workshop image which has been matched with the current version of the Educates operator.

The JDK workshop images are intended for workshops requiring Java. The Conda workshop image is intended for workshops which would benefit from the Anaconda distribution of Python, rather than the standard Python distribution supplied with the operating system image.
Expand Down
2 changes: 1 addition & 1 deletion project-docs/getting-started/workshop-templates.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ The command line options for customizing the fields and their purpose are:

* `--title` - A short title describing the workshop.
* `--description` - A longer description of the workshop.
* `--image` - The name of an alternate workshop base image to use for the workshop. Options for workshop base images supplied with Educates are `jdk8-environment:*`, `jdk11-environment:*`, `jdk17-environment:*` and `conda-environment:*`.
* `--image` - The name of an alternate workshop base image to use for the workshop. Options for workshop base images supplied with Educates are `jdk8-environment:*`, `jdk11-environment:*`, `jdk17-environment:*`, `jdk21-environment:*` and `conda-environment:*`.

Custom workshop base image
--------------------------
Expand Down
1 change: 1 addition & 0 deletions project-docs/release-notes/version-2.0.0.md
Original file line number Diff line number Diff line change
Expand Up @@ -287,6 +287,7 @@ Further, only the following short names for workshop images are now recognised i
* ``jdk8-environment:*`` - A tagged version of the ``jdk8-environment`` workshop image which has been matched with the current version of the Educates operator.
* ``jdk11-environment:*`` - A tagged version of the ``jdk11-environment`` workshop image which has been matched with the current version of the Educates operator.
* ``jdk17-environment:*`` - A tagged version of the ``jdk17-environment`` workshop image which has been matched with the current version of the Educates operator.
* ``jdk21-environment:*`` - A tagged version of the ``jdk21-environment`` workshop image which has been matched with the current version of the Educates operator.
* ``conda-environment:*`` - A tagged version of the ``conda-environment`` workshop image which has been matched with the current version of the Educates operator.

Prior short names with `master` and `develop` tags are no longer recognised.
Expand Down
2 changes: 2 additions & 0 deletions project-docs/release-notes/version-2.7.0.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@ New Features
status](workshop-environment-status) and [Listing all workshop
sessions](listing-all-workshop-sessions)

* Added `jdk21-environment` workshop base image.

Features Changed
----------------

Expand Down
10 changes: 10 additions & 0 deletions project-docs/workshop-content/building-an-image.md
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,16 @@ To see what specific tagged version of the image exist visit:

* [https://github.com/vmware-tanzu-labs/educates-training-platform/pkgs/container/educates-jdk17-environment](https://github.com/vmware-tanzu-labs/educates-training-platform/pkgs/container/educates-jdk17-environment)

The name of the JDK 21 version of the Java custom workshop base image is:

```
ghcr.io/vmware-tanzu-labs/educates-jdk21-environment:2.6
```

To see what specific tagged version of the image exist visit:

* [https://github.com/vmware-tanzu-labs/educates-training-platform/pkgs/container/educates-jdk21-environment](https://github.com/vmware-tanzu-labs/educates-training-platform/pkgs/container/educates-jdk21-environment)

The images will be updated over time to try and include the latest versions of Gradle and Maven. In case you are using Gradle or Maven wrapper scripts for selecting a specific version of these tools, configuration for these wrapper scripts is provided for the pre-installed version to avoid it being downloaded again.

If wanting to run workshops based around using Anaconda Python or Jupyter notebooks, the Educates project provides a suitable base environment.
Expand Down
2 changes: 2 additions & 0 deletions project-docs/workshop-migration/learning-center.md
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,8 @@ Note that whereas Learning Center only bundled a single workshop base image, Edu
``jdk17-environment:*`` - A tagged version of the ``jdk17-environment`` workshop image which has been matched with the current version of the Educates operator.
``jdk21-environment:*`` - A tagged version of the ``jdk21-environment`` workshop image which has been matched with the current version of the Educates operator.
``conda-environment:*`` - A tagged version of the ``conda-environment`` workshop image which has been matched with the current version of the Educates operator.
Downloading of workshop content
Expand Down
2 changes: 2 additions & 0 deletions session-manager/handlers/operator_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -147,13 +147,15 @@ def image_reference(name):
JDK8_ENVIRONMENT_IMAGE = image_reference("jdk8-environment")
JDK11_ENVIRONMENT_IMAGE = image_reference("jdk11-environment")
JDK17_ENVIRONMENT_IMAGE = image_reference("jdk17-environment")
JDK21_ENVIRONMENT_IMAGE = image_reference("jdk21-environment")
CONDA_ENVIRONMENT_IMAGE = image_reference("conda-environment")

workshop_images_table = {
"base-environment:*": BASE_ENVIRONMENT_IMAGE,
"jdk8-environment:*": JDK8_ENVIRONMENT_IMAGE,
"jdk11-environment:*": JDK11_ENVIRONMENT_IMAGE,
"jdk17-environment:*": JDK17_ENVIRONMENT_IMAGE,
"jdk21-environment:*": JDK21_ENVIRONMENT_IMAGE,
"conda-environment:*": CONDA_ENVIRONMENT_IMAGE,
}

Expand Down
10 changes: 5 additions & 5 deletions workshop-images/jdk11-environment/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,11 @@ RUN curl --fail -sL -o /tmp/maven.tar.gz https://archive.apache.org/dist/maven/m
tar -C /opt/maven --strip-components 1 -zxf /tmp/maven.tar.gz && \
rm /tmp/maven.tar.gz

RUN curl --fail -sL -o /tmp/gradle.zip https://services.gradle.org/distributions/gradle-7.6.1-bin.zip && \
echo "6147605a23b4eff6c334927a86ff3508cb5d6722cd624c97ded4c2e8640f1f87 /tmp/gradle.zip" | sha256sum --check --status && \
RUN curl --fail -sL -o /tmp/gradle.zip https://services.gradle.org/distributions/gradle-8.5-bin.zip && \
echo "9d926787066a081739e8200858338b4a69e837c3a821a33aca9db09dd4a41026 /tmp/gradle.zip" | sha256sum --check --status && \
unzip -d /opt/gradle /tmp/gradle.zip && \
mv /opt/gradle/gradle-7.6.1/* /opt/gradle/ && \
rm -rf /opt/gradle/gradle-7.6.1 && \
mv /opt/gradle/gradle-8.5/* /opt/gradle/ && \
rm -rf /opt/gradle/gradle-8.5 && \
rm /tmp/gradle.zip

ENV PATH=/opt/java/bin:/opt/gradle/bin:/opt/maven/bin:$PATH \
Expand All @@ -47,7 +47,7 @@ RUN mvn archetype:generate -DgroupId=com.mycompany.app -DartifactId=my-app \
mvn wrapper:wrapper

RUN gradle init && \
gradle wrapper --gradle-version=7.4.2 --distribution-type=bin && \
gradle wrapper --gradle-version=8.5 --distribution-type=bin && \
./gradlew build

FROM ${IMAGE_REPOSITORY}/${BASE_IMAGE_NAME}:${PACKAGE_VERSION}
Expand Down
10 changes: 5 additions & 5 deletions workshop-images/jdk17-environment/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,11 @@ RUN curl --fail -sL -o /tmp/maven.tar.gz https://archive.apache.org/dist/maven/m
tar -C /opt/maven --strip-components 1 -zxf /tmp/maven.tar.gz && \
rm /tmp/maven.tar.gz

RUN curl --fail -sL -o /tmp/gradle.zip https://services.gradle.org/distributions/gradle-7.6.1-bin.zip && \
echo "6147605a23b4eff6c334927a86ff3508cb5d6722cd624c97ded4c2e8640f1f87 /tmp/gradle.zip" | sha256sum --check --status && \
RUN curl --fail -sL -o /tmp/gradle.zip https://services.gradle.org/distributions/gradle-8.5-bin.zip && \
echo "9d926787066a081739e8200858338b4a69e837c3a821a33aca9db09dd4a41026 /tmp/gradle.zip" | sha256sum --check --status && \
unzip -d /opt/gradle /tmp/gradle.zip && \
mv /opt/gradle/gradle-7.6.1/* /opt/gradle/ && \
rm -rf /opt/gradle/gradle-7.6.1 && \
mv /opt/gradle/gradle-8.5/* /opt/gradle/ && \
rm -rf /opt/gradle/gradle-8.5 && \
rm /tmp/gradle.zip

ENV PATH=/opt/java/bin:/opt/gradle/bin:/opt/maven/bin:$PATH \
Expand All @@ -47,7 +47,7 @@ RUN mvn archetype:generate -DgroupId=com.mycompany.app -DartifactId=my-app \
mvn wrapper:wrapper

RUN gradle init && \
gradle wrapper --gradle-version=7.4.2 --distribution-type=bin && \
gradle wrapper --gradle-version=8.5 --distribution-type=bin && \
./gradlew build

FROM ${IMAGE_REPOSITORY}/${BASE_IMAGE_NAME}:${PACKAGE_VERSION}
Expand Down
66 changes: 66 additions & 0 deletions workshop-images/jdk21-environment/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
#syntax=docker/dockerfile:1.3-labs

ARG IMAGE_REPOSITORY=localhost:5001
ARG BASE_IMAGE_NAME=educates-base-environment
ARG PACKAGE_VERSION=latest

FROM ${IMAGE_REPOSITORY}/${BASE_IMAGE_NAME}:${PACKAGE_VERSION} AS scratch-image

ARG TARGETARCH

RUN mkdir -p /opt/{java,gradle,maven}

RUN <<EOF
set -eo pipefail
ARCHNAME_amd64=x64
ARCHNAME_arm64=aarch64
ARCHNAME=ARCHNAME_${TARGETARCH}
CHECKSUM_amd64="1a6fa8abda4c5caed915cfbeeb176e7fbd12eb6b222f26e290ee45808b529aa1"
CHECKSUM_arm64="e184dc29a6712c1f78754ab36fb48866583665fa345324f1a79e569c064f95e9"
CHECKSUM=CHECKSUM_${TARGETARCH}
curl --fail -sL -o /tmp/jdk21.tar.gz https://github.com/adoptium/temurin21-binaries/releases/download/jdk-21.0.1%2B12/OpenJDK21U-jdk_${!ARCHNAME}_linux_hotspot_21.0.1_12.tar.gz
echo "${!CHECKSUM} /tmp/jdk21.tar.gz" | sha256sum --check --status
tar -C /opt/java --strip-components 1 -zxf /tmp/jdk21.tar.gz
rm /tmp/jdk21.tar.gz
EOF

RUN curl --fail -sL -o /tmp/maven.tar.gz https://archive.apache.org/dist/maven/maven-3/3.9.2/binaries/apache-maven-3.9.2-bin.tar.gz && \
echo "900bdeeeae550d2d2b3920fe0e00e41b0069f32c019d566465015bdd1b3866395cbe016e22d95d25d51d3a5e614af2c83ec9b282d73309f644859bbad08b63db /tmp/maven.tar.gz" | sha512sum --check --status && \
tar -C /opt/maven --strip-components 1 -zxf /tmp/maven.tar.gz && \
rm /tmp/maven.tar.gz

RUN curl --fail -sL -o /tmp/gradle.zip https://services.gradle.org/distributions/gradle-8.5-bin.zip && \
echo "9d926787066a081739e8200858338b4a69e837c3a821a33aca9db09dd4a41026 /tmp/gradle.zip" | sha256sum --check --status && \
unzip -d /opt/gradle /tmp/gradle.zip && \
mv /opt/gradle/gradle-8.5/* /opt/gradle/ && \
rm -rf /opt/gradle/gradle-8.5 && \
rm /tmp/gradle.zip

ENV PATH=/opt/java/bin:/opt/gradle/bin:/opt/maven/bin:$PATH \
JAVA_HOME=/opt/java \
M2_HOME=/opt/maven

RUN mvn archetype:generate -DgroupId=com.mycompany.app -DartifactId=my-app \
-DarchetypeArtifactId=maven-archetype-quickstart \
-DarchetypeVersion=1.4 -DinteractiveMode=false && \
cd my-app && \
mvn wrapper:wrapper

RUN gradle init && \
gradle wrapper --gradle-version=8.5 --distribution-type=bin && \
./gradlew build

FROM ${IMAGE_REPOSITORY}/${BASE_IMAGE_NAME}:${PACKAGE_VERSION}

COPY --from=scratch-image --chown=1001:0 /opt/java /opt/java
COPY --from=scratch-image --chown=1001:0 /opt/gradle /opt/gradle
COPY --from=scratch-image --chown=1001:0 /opt/maven /opt/maven

COPY --from=scratch-image --chown=1001:0 /home/eduk8s/.m2 /home/eduk8s/.m2
COPY --from=scratch-image --chown=1001:0 /home/eduk8s/.gradle /home/eduk8s/.gradle

COPY --chown=1001:0 opt/. /opt/

ENV PATH=/opt/java/bin:/opt/gradle/bin:/opt/maven/bin:$PATH \
JAVA_HOME=/opt/java \
M2_HOME=/opt/maven
21 changes: 21 additions & 0 deletions workshop-images/jdk21-environment/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
JDK21 Environment
=================

This directory holds the source code for the workshop JDK21 environment image.

It can be used as a base image for constructing a custom workshop image which
includes workshop content, or can be used as the workshop image declared in the
workshop YAML definition, with workshop files pulled down from a GitHub
repository when the workshop session is created.

```
apiVersion: training.educates.dev/v1beta1
kind: Workshop
metadata:
name: lab-java-workshop
spec:
title: Java Testing
description: Test of JDK21 environment.
workshop:
image: jdk21-environment:*
```
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#!/bin/sh

SETTINGS=$HOME/.local/share/code-server/User/settings.json

jq -M '. + {
"java.configuration.checkProjectSettingsExclusions": false,
"java.help.firstView": "overview",
"java.semanticHighlighting.enabled": false,
"files.exclude": {
"**/.classpath": true,
"**/.project": true,
"**/.settings": true,
"**/.factorypath": true
}
}' $SETTINGS > $SETTINGS.$$

mv $SETTINGS.$$ $SETTINGS
10 changes: 5 additions & 5 deletions workshop-images/jdk8-environment/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,11 @@ RUN curl --fail -sL -o /tmp/maven.tar.gz https://archive.apache.org/dist/maven/m
tar -C /opt/maven --strip-components 1 -zxf /tmp/maven.tar.gz && \
rm /tmp/maven.tar.gz

RUN curl --fail -sL -o /tmp/gradle.zip https://services.gradle.org/distributions/gradle-7.6.1-bin.zip && \
echo "6147605a23b4eff6c334927a86ff3508cb5d6722cd624c97ded4c2e8640f1f87 /tmp/gradle.zip" | sha256sum --check --status && \
RUN curl --fail -sL -o /tmp/gradle.zip https://services.gradle.org/distributions/gradle-8.5-bin.zip && \
echo "9d926787066a081739e8200858338b4a69e837c3a821a33aca9db09dd4a41026 /tmp/gradle.zip" | sha256sum --check --status && \
unzip -d /opt/gradle /tmp/gradle.zip && \
mv /opt/gradle/gradle-7.6.1/* /opt/gradle/ && \
rm -rf /opt/gradle/gradle-7.6.1 && \
mv /opt/gradle/gradle-8.5/* /opt/gradle/ && \
rm -rf /opt/gradle/gradle-8.5 && \
rm /tmp/gradle.zip

ENV PATH=/opt/java/bin:/opt/gradle/bin:/opt/maven/bin:$PATH \
Expand All @@ -47,7 +47,7 @@ RUN mvn archetype:generate -DgroupId=com.mycompany.app -DartifactId=my-app \
mvn wrapper:wrapper

RUN gradle init && \
gradle wrapper --gradle-version=7.4.2 --distribution-type=bin && \
gradle wrapper --gradle-version=8.5 --distribution-type=bin && \
./gradlew build

FROM ${IMAGE_REPOSITORY}/${BASE_IMAGE_NAME}:${PACKAGE_VERSION}
Expand Down

0 comments on commit 4c6985a

Please sign in to comment.