marco-luzzara commented on PR #396: URL: https://github.com/apache/ranger/pull/396#issuecomment-2501154878
> @marco-luzzara, @kumaab - docker build fails with this patch as well. Is it okay to use "if" condition in RUN command? > > ``` > $ docker-compose -f docker-compose.ranger-base.yml -f docker-compose.ranger-build.yml up > WARN[0000] /home/ranger/dev-support/ranger-docker/docker-compose.ranger-base.yml: the attribute `version` is obsolete, it will be ignored, please remove it to avoid potential confusion > WARN[0000] /home/ranger/dev-support/ranger-docker/docker-compose.ranger-build.yml: the attribute `version` is obsolete, it will be ignored, please remove it to avoid potential confusion > [+] Running 2/2 > ! ranger-build Warning pull access denied for ranger-build, repository does not exist or may require 'docker login': denied: requested access to the resource is denied 1.3s > ! ranger-base Warning pull access denied for ranger-base, repository does not exist or may require 'docker login': denied: requested access to the resource is denied 1.3s > [+] Building 4.3s (15/18) docker:desktop-linux > => [ranger-base internal] load build definition from Dockerfile.ranger-base 0.0s > => => transferring dockerfile: 2.58kB 0.0s > => WARN: InvalidDefaultArgInFrom: Default value for ARG ubuntu:${UBUNTU_VERSION} results in empty or invalid base image name (line 18) 0.0s > => [ranger-base internal] load metadata for docker.io/library/ubuntu:20.04 0.8s > => [ranger-base internal] load .dockerignore 0.0s > => => transferring context: 481B 0.0s > => [ranger-base 1/4] FROM docker.io/library/ubuntu:20.04@sha256:8e5c4f0285ecbb4ead070431d29b576a530d3166df73ec44affc1cd27555141b 0.0s > => CACHED [ranger-base 2/4] RUN apt-get update && DEBIAN_FRONTEND="noninteractive" apt-get -y install tzdata vim python3 python3-pip openjdk-8-jdk openjdk-11-jdk openjdk-17-jdk bc iputils-ping ssh pdsh xmlstarlet && pip3 install apache-rang 0.0s > => CACHED [ranger-base 3/4] RUN update-java-alternatives --set /usr/lib/jvm/java-1.8.0-openjdk-arm64 0.0s > => CACHED [ranger-base 4/4] RUN groupadd ranger && useradd -g ranger -ms /bin/bash ranger && useradd -g ranger -ms /bin/bash rangeradmin && useradd -g ranger -ms /bin/bash rangerusersync && useradd -g ranger -ms /bin/bash rangertagsync 0.0s > => [ranger-base] exporting to image 0.0s > => => exporting layers 0.0s > => => writing image sha256:136cb5af62fd3431f5b75951a22a356df1bfbdef184659f30f40e2c3dbf7a74b 0.0s > => => naming to docker.io/library/ranger-base 0.0s > => [ranger-base] resolving provenance for metadata file 0.0s > => [ranger-build internal] load build definition from Dockerfile.ranger-build 0.0s > => => transferring dockerfile: 1.86kB 0.0s > => [ranger-build internal] load metadata for docker.io/library/ranger-base:latest 0.0s > => [ranger-build internal] load .dockerignore 0.0s > => => transferring context: 481B 0.0s > => CACHED [ranger-build 1/5] FROM docker.io/library/ranger-base:latest 0.0s > => [ranger-build internal] load build context 0.0s > => => transferring context: 109B 0.0s > => ERROR [ranger-build 2/5] RUN if [ "UBUNTU" = "UBUNTU" ]; then apt-get update && apt-get -y install git maven build-essential update-java-alternatives --set "/usr/lib/jvm/java-1.8.0-openjdk-arm64"; fi 3.2s > ------ > > [ranger-build 2/5] RUN if [ "UBUNTU" = "UBUNTU" ]; then apt-get update && apt-get -y install git maven build-essential update-java-alternatives --set "/usr/lib/jvm/java-1.8.0-openjdk-arm64"; fi: > 0.700 Hit:1 http://ports.ubuntu.com/ubuntu-ports focal InRelease > 0.837 Get:2 http://ports.ubuntu.com/ubuntu-ports focal-updates InRelease [128 kB] > 1.490 Get:3 http://ports.ubuntu.com/ubuntu-ports focal-backports InRelease [128 kB] > 1.755 Get:4 http://ports.ubuntu.com/ubuntu-ports focal-security InRelease [128 kB] > 1.989 Get:5 http://ports.ubuntu.com/ubuntu-ports focal-updates/main arm64 Packages [3519 kB] > 2.738 Get:6 http://ports.ubuntu.com/ubuntu-ports focal-updates/universe arm64 Packages [1472 kB] > 2.887 Fetched 5375 kB in 3s (1937 kB/s) > 2.887 Reading package lists... > 3.218 E: Command line option --set is not understood in combination with the other options > ------ > failed to solve: process "/bin/sh -c if [ \"${OS_NAME}\" = \"UBUNTU\" ]; then apt-get update && apt-get -y install git maven build-essential update-java-alternatives --set \"$JAVA_HOME\"; fi" did not complete successfully: exit code: 100 > ``` You certainly can use 'if' inside RUN commands, the issue in this patch seems to be the missing `&&` to split `apt-get` and `update-java-alternatives`. When I created this PR I had already fixed the issue locally, but I used RUN with heredocs strings. Then I converted it to a retro-compatible version (by replacing the `RUN <<EOF` with a simple `RUN`) and I made this mistake. Thank you for fixing it @kumaab! -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: dev-unsubscr...@ranger.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org