在基于Alpine的Docker映像中安装Sdkman

时间:2020-08-10 07:50:06

标签: docker alpine sdkman

我需要在基于Alpine的docker映像中安装Sdkman,但是存在一个问题,即默认shell不是Bash。然后命令:

source "$HOME/.sdkman/bin/sdkman-init.sh"

以失败告终:

/bin/sh: /root/.sdkman/bin/sdkman-init.sh: line 40: SDKMAN_PLATFORM+=64: not found 

1 个答案:

答案 0 :(得分:2)

您需要将SDKMAN的安装分成两个部分,然后将init脚本运行到两个RUN块中。

RUN apk add bash curl git zip && \
  curl -s "https://get.sdkman.io" | bash
RUN bash -c "source $HOME/.sdkman/bin/sdkman-init.sh && sdk version"

来源:https://e.printstacktrace.blog/using-sdkman-as-a-docker-image-for-jenkins-pipeline-a-step-by-step-guide/