How noninteractive install latest java version by sdkman?
Asked Answered
F

1

6

In our CI/CD environment we have couple docker images with preinstalled java by sdkman. But there is one small problem, version number changes very often and our docker build fails because of missing package version. Eg.:

sdk install java 8.0.232-zulu

Stop! java 8.0.232-zulu is not available. Possible causes:
 * 8.0.232-zulu is an invalid version
 * java binaries are incompatible with Linux64
 * java has not been released yet

Is there any option to non-interactive install latest java in sepecyfic "flavour" and version?

Something like: sdk install java 8-zulu-latest

PS. For now, as (ugly) workaround we use sdk install java $(sdk list java | grep -e 8\.0\..*-zulu[^fx] | sed -r s/^.*8/8/)

Febrifugal answered 18/3, 2020 at 15:1 Comment(0)
D
2

One way to do it would be not to depend on SDKMAN!.

Since you're under a docker environment, it is desirable to also keep image size to a minimum.

Here is an example of installing the latest zulu JDK under alpine:


FROM alpine as base

# install zulu jdk
RUN apk --update --no-cache add curl \
    && curl https://cdn.azul.com/public_keys/[email protected] > /etc/apk/keys/[email protected] \
    && echo "https://repos.azul.com/zulu/alpine" >> /etc/apk/repositories \
    && apk --update --no-cache add zulu8-jdk \
    && apk del curl

This will download curl, the product signing key and add the zulu alpine repository to the apk repositories list, install the latest available zulu8-jdk and delete curl.

Please note that you can also replace the JDK version in the name. For example, use zulu11-jdk in order to install JDK 11.

Some useful zulu installation references:

https://docs.azul.com/zulu/zuludocs/ZuluUserGuide/InstallingZulu/InstallOnLinuxUsingAPKRepository.htm

https://docs.azul.com/zulu/zuludocs/ZuluUserGuide/PrepareZuluPlatform/AttachAPKRepositoryAlpineLinux.htm

Discomfit answered 10/4, 2021 at 20:10 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.