From 2cf674d155569fff2d4b101a181ff4dd7c3730ac Mon Sep 17 00:00:00 2001 From: ZettWire Date: Thu, 21 Nov 2024 15:59:46 +0100 Subject: [PATCH] Add script to install helm for dynamic OS and ARCH (#521) --- onyxia-api/Dockerfile | 10 +++++----- onyxia-api/install-helm.sh | 37 +++++++++++++++++++++++++++++++++++++ 2 files changed, 42 insertions(+), 5 deletions(-) create mode 100755 onyxia-api/install-helm.sh diff --git a/onyxia-api/Dockerfile b/onyxia-api/Dockerfile index f8045caa..9af0aa94 100644 --- a/onyxia-api/Dockerfile +++ b/onyxia-api/Dockerfile @@ -6,16 +6,16 @@ RUN java -Djarmode=layertools -jar application.jar extract FROM eclipse-temurin:21.0.4_7-jre WORKDIR /app # Install helm -RUN wget https://get.helm.sh/helm-v3.16.1-linux-amd64.tar.gz -RUN tar -zxvf helm-v3.16.1-linux-amd64.tar.gz -RUN mv linux-amd64/helm /usr/local/bin/helm -RUN rm helm-v3.16.1-linux-amd64.tar.gz -RUN rm -rf linux-amd64 +COPY install-helm.sh install-helm.sh +RUN ./install-helm.sh +RUN rm install-helm.sh +# Create onyxia group and user RUN groupadd --gid 101 --system onyxia && \ useradd --system --uid 101 --create-home --home-dir /var/cache/onyxia --shell /sbin/nologin --gid onyxia --comment onyxia onyxia # Allow adding CA certificates ENV CACERTS_DIR="/usr/local/share/ca-certificates" RUN chown onyxia $JAVA_HOME/lib/security/cacerts +# copy build extraction COPY --from=extract dependencies/ ./ COPY --from=extract snapshot-dependencies/ ./ COPY --from=extract spring-boot-loader/ ./ diff --git a/onyxia-api/install-helm.sh b/onyxia-api/install-helm.sh new file mode 100755 index 00000000..fb57a378 --- /dev/null +++ b/onyxia-api/install-helm.sh @@ -0,0 +1,37 @@ +#! /bin/bash +HELM_VERSION=v3.16.1 + +# initOS discovers the operating system for this system. +initOS() { + OS=$(echo `uname`|tr '[:upper:]' '[:lower:]') + + case "$OS" in + # Minimalist GNU for Windows + mingw*|cygwin*) OS='windows';; + esac +} + +# initArch discovers the architecture for this system. +initArch() { + ARCH=$(uname -m) + case $ARCH in + armv5*) ARCH="armv5";; + armv6*) ARCH="armv6";; + armv7*) ARCH="arm";; + aarch64) ARCH="arm64";; + x86) ARCH="386";; + x86_64) ARCH="amd64";; + i686) ARCH="386";; + i386) ARCH="386";; + esac +} + +initOS +initArch +HELM_DIST="helm-${HELM_VERSION}-${OS}-${ARCH}.tar.gz" +wget https://get.helm.sh/${HELM_DIST} +tar -zxvf ${HELM_DIST} +mv ${OS}-${ARCH}/helm /usr/local/bin/helm +rm ${HELM_DIST} +rm -rf ${OS}-${ARCH} +