You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@ranger.apache.org by "marco-luzzara (via GitHub)" <gi...@apache.org> on 2024/09/26 14:45:21 UTC

[PR] RANGER-4942: Fix Dockerfiles of ./build_ranger_using_docker.sh [ranger]

marco-luzzara opened a new pull request, #396:
URL: https://github.com/apache/ranger/pull/396

   ## What changes were proposed in this pull request?
   
   This PR fixes some syntactic mistakes on the Dockerfiles involved in the Ranger build in a Dockerized environment. The 3 main issues I have fixed are:
   
   - `RUN if [ "${OS_NAME}" == "UBUNTU" ]; then ...`: the commands enclosed in this if-condition will never be executed because the shell used for this command is `/bin/sh`, which requires a single `=` for string comparison.
   - For some reasons, the `ENV JAVA_HOME /usr/lib/...` Dockerfile command is placed inside the `RUN` command. I put it before the `RUN` command in order to use the `JAVA_HOME` env variable in the shell script.
   - Many env variables are initialized using the alternative syntax `ENV MY_ENV_VAR value1`, which is not compliant with the guidelines, that suggests using `ENV MY_ENV_VAR=value1`. I quote from the [`ENV` reference](https://docs.docker.com/reference/dockerfile/#env): 
     > The alternative syntax is supported for backward compatibility, but discouraged for the reasons outlined above, and may be removed in a future release.
     
     I rewrote only some of them, in case you preferred another PR for a general Dockerfile/compose improvements.
   
   
   
   ## How was this patch tested?
   
   By running `./build_ranger_using_docker.sh`
   


-- 
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-unsubscribe@ranger.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] RANGER-4942: Fix Dockerfiles of ./build_ranger_using_docker.sh [ranger]

Posted by "kumaab (via GitHub)" <gi...@apache.org>.
kumaab commented on PR #396:
URL: https://github.com/apache/ranger/pull/396#issuecomment-2499535886

   Thank you @marco-luzzara for reporting the above mentioned issues, here is a revised patch which builds on this patch: #416.


-- 
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-unsubscribe@ranger.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] RANGER-4942: Fix Dockerfiles of ./build_ranger_using_docker.sh [ranger]

Posted by "kumaab (via GitHub)" <gi...@apache.org>.
kumaab commented on PR #396:
URL: https://github.com/apache/ranger/pull/396#issuecomment-2504902317

   @marco-luzzara: The proposed changes have been merged to master: 21b8ca9d966787183a167c2f3456ce7ea1e367db, you may close the pull request, thank you.


-- 
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-unsubscribe@ranger.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] RANGER-4942: Fix Dockerfiles of ./build_ranger_using_docker.sh [ranger]

Posted by "kumaab (via GitHub)" <gi...@apache.org>.
kumaab commented on PR #396:
URL: https://github.com/apache/ranger/pull/396#issuecomment-2499936723

   @mneethiraj: This patch is working: https://github.com/apache/ranger/pull/416 please try. 


-- 
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-unsubscribe@ranger.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] RANGER-4942: Fix Dockerfiles of ./build_ranger_using_docker.sh [ranger]

Posted by "mneethiraj (via GitHub)" <gi...@apache.org>.
mneethiraj commented on PR #396:
URL: https://github.com/apache/ranger/pull/396#issuecomment-2499826551

   @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
   
   ```


-- 
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-unsubscribe@ranger.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] RANGER-4942: Fix Dockerfiles of ./build_ranger_using_docker.sh [ranger]

Posted by "marco-luzzara (via GitHub)" <gi...@apache.org>.
marco-luzzara closed pull request #396: RANGER-4942: Fix Dockerfiles of ./build_ranger_using_docker.sh
URL: https://github.com/apache/ranger/pull/396


-- 
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-unsubscribe@ranger.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] RANGER-4942: Fix Dockerfiles of ./build_ranger_using_docker.sh [ranger]

Posted by "marco-luzzara (via GitHub)" <gi...@apache.org>.
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-unsubscribe@ranger.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org