From 417da0743856284cd4d38b7de3c492ec09a92954 Mon Sep 17 00:00:00 2001 From: antromeo <45900043+antromeo@users.noreply.github.com> Date: Wed, 7 Feb 2024 17:53:56 +0100 Subject: [PATCH] ENG-5472: adds node and java version as arg --- .github/workflows/multi-arch.yml | 4 ++++ Dockerfile.GitHub | 22 +++++++++++++----- Dockerfile.OCP | 38 +++++++++++++++++++------------- utils/activate-ent.sh | 7 ++---- 4 files changed, 46 insertions(+), 25 deletions(-) diff --git a/.github/workflows/multi-arch.yml b/.github/workflows/multi-arch.yml index 07ac6edc..dc9f5166 100644 --- a/.github/workflows/multi-arch.yml +++ b/.github/workflows/multi-arch.yml @@ -68,6 +68,8 @@ jobs: build-args: | ENTANDO_VERSION=${{ vars.ENTANDO_RELEASE }} ENT_CLI_VERSION=${{ github.ref_name }} + NODE_VERSION=${{ vars.NODE_VERSION }} + JAVA_VERSION=${{ vars.JAVA_VERSION }} labels: ${{ steps.meta-ent-cli-github.outputs.labels }} platforms: linux/amd64 @@ -82,5 +84,7 @@ jobs: ENTANDO_VERSION=${{ vars.ENTANDO_RELEASE }} ENT_CLI_VERSION=${{ github.ref_name }} KUBECTL_RELEASE=${{ vars.KUBECTL_RELEASE }} + NODE_VERSION=${{ vars.NODE_VERSION }} + JAVA_VERSION=${{ vars.JAVA_VERSION }} labels: ${{ steps.meta-ent-cli-ocp.outputs.labels }} platforms: linux/amd64 diff --git a/Dockerfile.GitHub b/Dockerfile.GitHub index aca52f8d..a3b2f47c 100644 --- a/Dockerfile.GitHub +++ b/Dockerfile.GitHub @@ -1,16 +1,28 @@ -FROM alpine:3.17.1 +FROM debian:11.9-slim ARG ENT_CLI_VERSION ARG ENTANDO_VERSION ARG APP=/home/ent ARG BUNDLE_CLI_VERSION +ARG JAVA_VERSION=11 +ARG NODE_VERSION ENV PATH=$APP/.entando/ent/$ENTANDO_VERSION/cli/$ENT_CLI_VERSION/bin:$APP/.entando/bin:$PATH \ ENTANDO_ENT_HOME=$APP/.entando/ent/$ENTANDO_VERSION/cli/$ENT_CLI_VERSION \ BUNDLE_CLI_VERSION=$BUNDLE_CLI_VERSION \ + NODE_VERSION=$NODE_VERSION \ HOME=$APP -RUN apk add --no-cache openjdk11 maven perl bash git tree jq curl grep gcompat libstdc++ docker +RUN apt-get update && apt-get -y install openjdk-$JAVA_VERSION-jdk maven perl git tree jq curl grep ca-certificates && \ + apt-get -y autoclean && apt-get -y autoremove && \ + install -m 0755 -d /etc/apt/keyrings && \ + curl -fsSL https://download.docker.com/linux/ubuntu/gpg -o /etc/apt/keyrings/docker.asc && \ + chmod a+r /etc/apt/keyrings/docker.asc && \ + echo "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.asc] https://download.docker.com/linux/debian \ + $(. /etc/os-release && echo "$VERSION_CODENAME") stable" | \ + tee /etc/apt/sources.list.d/docker.list > /dev/null && \ + apt-get update && \ + apt-get -y install docker-ce docker-ce-cli WORKDIR $APP @@ -18,7 +30,7 @@ COPY utils/activate-ent.sh $APP RUN chmod +x $APP/activate-ent.sh -RUN bash <(curl -sfL https://get.entando.org/cli) --update --release="$ENTANDO_VERSION" --cli-version="$ENT_CLI_VERSION" && \ - bash $APP/activate-ent.sh +RUN /bin/bash -c "bash <(curl -sfL https://get.entando.org/cli) --update --release=$ENTANDO_VERSION --cli-version=$ENT_CLI_VERSION" && \ + /bin/bash -c "bash $APP/activate-ent.sh" -CMD ["/bin/bash"] +CMD ["/bin/bash"] \ No newline at end of file diff --git a/Dockerfile.OCP b/Dockerfile.OCP index e0b87009..d5badbca 100644 --- a/Dockerfile.OCP +++ b/Dockerfile.OCP @@ -1,46 +1,54 @@ -FROM alpine:3.17.1 +FROM debian:11.9-slim # REGISTRY=https://registry.npmjs.org \ ARG ENTANDO_VERSION ARG ENT_CLI_VERSION ARG KUBECTL_RELEASE ARG BUNDLE_CLI_VERSION +ARG ENTANDO_USER_ID=65532 +ARG ENTANDO_USER=ent +ARG JAVA_VERSION=11 +ARG NODE_VERSION ENV BASH_ENV=/usr/local/bin/scl_enable \ ENTANDO_VERSION=$ENTANDO_VERSION \ BUNDLE_CLI_VERSION=$BUNDLE_CLI_VERSION \ - PATH=$PATH:/home/ent/.entando/ent/$ENTANDO_VERSION/cli/$ENT_CLI_VERSION/bin:/home/ent/.entando/ent/$ENTANDO_VERSION/opt/node-v14.20.0/bin \ + NODE_VERSION=$NODE_VERSION \ + PATH=$PATH:/home/ent/.entando/ent/$ENTANDO_VERSION/cli/$ENT_CLI_VERSION/bin:/home/ent/.entando/ent/$ENTANDO_VERSION/opt/node-$NODE_VERSION/bin \ ENTANDO_ENT_HOME=/home/ent/.entando/ent/$ENTANDO_VERSION/cli/$ENT_CLI_VERSION \ ENV=/usr/local/bin/scl_enable \ KUBECTL_RELEASE=$KUBECTL_RELEASE -COPY utils/docker /bin/docker -COPY utils/activate-ent.sh /home/ent/ - -RUN apk add --no-cache openjdk11 maven perl bash git tree jq curl grep libstdc++ gcompat && \ +RUN apt-get update && apt-get -y install openjdk-$JAVA_VERSION-jdk maven perl git tree jq curl grep && \ + apt-get -y autoclean && apt-get -y autoremove && \ curl -LO https://dl.k8s.io/release/$KUBECTL_RELEASE/bin/linux/amd64/kubectl && \ chmod +x kubectl && \ mv ./kubectl /bin/kubectl && \ - adduser -u 1000 -s /bin/bash -D ent -g 0 -G root && \ - chmod +x /bin/docker && \ - chmod +x /home/ent/activate-ent.sh + useradd -ms /bin/bash $ENTANDO_USER --uid $ENTANDO_USER_ID --groups 0 + +COPY utils/docker /bin/docker +COPY utils/activate-ent.sh /home/ent/ + +RUN chmod +x /home/ent/activate-ent.sh && \ + chown $ENTANDO_USER: /home/ent/activate-ent.sh && \ + chmod +x /bin/docker -USER 1000 +USER $ENTANDO_USER WORKDIR /home/ent -RUN bash <(curl -sfL https://get.entando.org/cli) --update --release="$ENTANDO_VERSION" --cli-version="$ENT_CLI_VERSION" && \ - bash ./activate-ent.sh +RUN /bin/bash -c "bash <(curl -sfL https://get.entando.org/cli) --update --release=$ENTANDO_VERSION --cli-version=$ENT_CLI_VERSION" && \ + /bin/bash -c "bash ./activate-ent.sh" USER 0 RUN chmod 0777 -R $ENTANDO_ENT_HOME/w && \ - mkdir -p /home/ent/.entando/ent/$ENTANDO_VERSION/opt/node-v14.20.0/etc && \ - chmod 0777 -R /home/ent/.entando/ent/$ENTANDO_VERSION/opt/node-v14.20.0/etc && \ + mkdir -p /home/ent/.entando/ent/$ENTANDO_VERSION/opt/node-$NODE_VERSION/etc && \ + chmod 0777 -R /home/ent/.entando/ent/$ENTANDO_VERSION/opt/node-$NODE_VERSION/etc && \ mkdir -p /entando-app && chmod 0777 -R /entando-app -USER 1000 +USER $ENTANDO_USER WORKDIR /entando-app diff --git a/utils/activate-ent.sh b/utils/activate-ent.sh index ed5106af..648be144 100644 --- a/utils/activate-ent.sh +++ b/utils/activate-ent.sh @@ -2,9 +2,6 @@ set -eux echo "BUNDLE_CLI_VERSION: $BUNDLE_CLI_VERSION" +echo "NODE_VERSION: $NODE_VERSION" -if [ -n "$BUNDLE_CLI_VERSION" ] ; then - ent check-env develop --yes --entando-bundle-cli-version="$BUNDLE_CLI_VERSION" --lenient -else - ent check-env develop --yes --lenient -fi \ No newline at end of file +ent check-env develop --yes --entando-bundle-cli-version="$BUNDLE_CLI_VERSION" --node-version="$NODE_VERSION" --lenient \ No newline at end of file