Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(debian_jdk17) revert #310 and use TARGETPLATFORM to detect if arm/v7 or not #324

Merged
merged 1 commit into from
Nov 16, 2022

Conversation

dduportal
Copy link
Contributor

@dduportal dduportal commented Nov 16, 2022

Related to #323 and #308.

This PR reverts #310 and fixes #308 with a similar approach but with the "conditionnality" of the arm/v7 directly inside the Dockerfile 's jre-build stage.

While reading https://www.docker.com/blog/faster-multi-platform-builds-dockerfile-cross-compilation-guide/, I confirmed @carpnick 's analysis about the BUILDPLATFORM. But it seems that Docker provides another variable which is TARGETPLATFORM which is populated with the value we expect.

https://docs.docker.com/engine/reference/builder/#automatic-platform-args-in-the-global-scope shows the documentation reference with an exemple on "how to" use this variable as a build argument: is is what this PR does.

Tested locally with a local registry and a "smoke test":

# Start a local registry to test the `--push` option
$ docker run -d -p 5000:5000 --restart=always --name registry registry:2

# A buildx runner is required to test multi-arch, but it's allowed to reach the `localhost:5000` of the Docker Engine which points to the registry through the Docker port forwarding
$ docker buildx create --use --driver-opt network=host 

# Build and push to the local registry
$ REGISTRY=localhost:5000 JENKINS_REPO=agent docker buildx bake --file docker-bake.hcl --push debian_jdk17

# Smoke tests
for arch in 'linux/amd64' 'linux/arm64' 'linux/arm/v7'; do echo "==$arch=="; docker run --platform="$arch" --rm --entrypoint='' localhost:5000/agent:jdk17 sh -c 'uname -m && java -version';done
==linux/amd64==
Unable to find image 'localhost:5000/agent:jdk17' locally
jdk17: Pulling from agent
Digest: sha256:385f9ebe6a724ac32447eaab2c945fef3d0db1bad558a50b7ae39c765b33a7e9
Status: Downloaded newer image for localhost:5000/agent:jdk17
x86_64
openjdk version "17.0.5" 2022-10-18
OpenJDK Runtime Environment Temurin-17.0.5+8 (build 17.0.5+8)
OpenJDK 64-Bit Server VM Temurin-17.0.5+8 (build 17.0.5+8, mixed mode)
==linux/arm64==
Unable to find image 'localhost:5000/agent:jdk17' locally
jdk17: Pulling from agent
Digest: sha256:385f9ebe6a724ac32447eaab2c945fef3d0db1bad558a50b7ae39c765b33a7e9
Status: Downloaded newer image for localhost:5000/agent:jdk17
aarch64
openjdk version "17.0.5" 2022-10-18
OpenJDK Runtime Environment Temurin-17.0.5+8 (build 17.0.5+8)
OpenJDK 64-Bit Server VM Temurin-17.0.5+8 (build 17.0.5+8, mixed mode)
==linux/arm/v7==
Unable to find image 'localhost:5000/agent:jdk17' locally
jdk17: Pulling from agent
Digest: sha256:385f9ebe6a724ac32447eaab2c945fef3d0db1bad558a50b7ae39c765b33a7e9
Status: Downloaded newer image for localhost:5000/agent:jdk17
armv7l
openjdk version "17.0.5" 2022-10-18
OpenJDK Runtime Environment Temurin-17.0.5+8 (build 17.0.5+8)
OpenJDK Server VM Temurin-17.0.5+8 (build 17.0.5+8, mixed mode, sharing)
  • Make sure you are opening from a topic/feature/bugfix branch (right side) and not your main branch!
  • Ensure that the pull request title represents the desired changelog entry
  • Please describe what you did
  • Link to relevant issues in GitHub or Jira
  • Link to relevant pull requests, esp. upstream and downstream changes
  • Ensure you have provided tests - that demonstrates feature works or fixes the issue

… not

Signed-off-by: Damien Duportal <damien.duportal@gmail.com>
@dduportal dduportal added the bug label Nov 16, 2022
@dduportal dduportal changed the title fix(debian_jdk17) revert #310 and use to detect if arm/v7 or not fix(debian_jdk17) revert #310 and use TARGETPLATFORM to detect if arm/v7 or not Nov 16, 2022
@dduportal dduportal marked this pull request as ready for review November 16, 2022 07:05
@dduportal dduportal requested a review from a team as a code owner November 16, 2022 07:05
@dduportal dduportal requested a review from timja November 16, 2022 07:06
@dduportal dduportal merged commit 50cd097 into jenkinsci:master Nov 16, 2022
@dduportal dduportal deleted the fix/debian_jdk17/cpu-archs branch November 16, 2022 16:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

JDK 17 ARM64 doesnt work - Java cannot run in AWS Fargate
2 participants