diff --git a/dev-support/ranger-docker/.env b/dev-support/ranger-docker/.env index 60bc4a9f27..22d7a2ac8c 100644 --- a/dev-support/ranger-docker/.env +++ b/dev-support/ranger-docker/.env @@ -4,11 +4,16 @@ GIT_URL=https://github.com/apache/ranger.git BRANCH=master PROFILE= -# Java version for RangerBase image. +# Java version for RangerBase ubuntu image. # This image gets used as base docker image for all images. # Valid values: 8, 11, 17 RANGER_BASE_JAVA_VERSION=8 +# Java version for RangerBase ubi image. +# This image gets used as base docker image for all images. +# Valid values: 1.8.0, 11, 17 +RANGER_BASE_UBI_JAVA_VERSION=1.8.0 + # Java version to use to build Apache Ranger # Valid values: 8, 11, 17 RANGER_BUILD_JAVA_VERSION=8 @@ -17,8 +22,11 @@ RANGER_BUILD_JAVA_VERSION=8 # Valid values: 8, 11, 17 RANGER_ADMIN_JAVA_VERSION=8 -# base & third party images +# base image versions UBUNTU_VERSION=20.04 +UBI_VERSION=9.2-750.1697625013 + +# third party image versions MARIADB_VERSION=10.7.3 POSTGRES_VERSION=12 ENABLE_DB_MOUNT=true diff --git a/dev-support/ranger-docker/Dockerfile.ranger b/dev-support/ranger-docker/Dockerfile.ranger index 28e19ea0f6..c938fa9f54 100644 --- a/dev-support/ranger-docker/Dockerfile.ranger +++ b/dev-support/ranger-docker/Dockerfile.ranger @@ -22,8 +22,10 @@ ARG RANGER_DB_TYPE ARG TARGETARCH ARG RANGER_ADMIN_JAVA_VERSION -ENV JAVA_HOME /usr/lib/jvm/java-${RANGER_ADMIN_JAVA_VERSION}-openjdk-${TARGETARCH} -RUN update-java-alternatives --set /usr/lib/jvm/java-1.${RANGER_ADMIN_JAVA_VERSION}.0-openjdk-${TARGETARCH} +RUN if [ "${OS_NAME}" == "UBUNTU" ]; then\ + ENV JAVA_HOME /usr/lib/jvm/java-${RANGER_ADMIN_JAVA_VERSION}-openjdk-${TARGETARCH}\ + update-java-alternatives --set /usr/lib/jvm/java-1.${RANGER_ADMIN_JAVA_VERSION}.0-openjdk-${TARGETARCH};\ + fi COPY ./dist/version /home/ranger/dist/ COPY ./dist/ranger-${RANGER_VERSION}-admin.tar.gz /home/ranger/dist/ diff --git a/dev-support/ranger-docker/Dockerfile.ranger-base b/dev-support/ranger-docker/Dockerfile.ranger-base index 72a850482a..e9e0f1aae9 100644 --- a/dev-support/ranger-docker/Dockerfile.ranger-base +++ b/dev-support/ranger-docker/Dockerfile.ranger-base @@ -19,6 +19,7 @@ FROM ubuntu:${UBUNTU_VERSION} ARG TARGETARCH ARG RANGER_BASE_JAVA_VERSION +ENV OS_NAME UBUNTU # Install tzdata, Python, Java, python-requests RUN apt-get update && \ diff --git a/dev-support/ranger-docker/Dockerfile.ranger-base-ubi b/dev-support/ranger-docker/Dockerfile.ranger-base-ubi new file mode 100644 index 0000000000..9882c031c1 --- /dev/null +++ b/dev-support/ranger-docker/Dockerfile.ranger-base-ubi @@ -0,0 +1,65 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +ARG UBI_VERSION +FROM registry.access.redhat.com/ubi9-minimal:${UBI_VERSION} + +USER root +ARG RANGER_BASE_JAVA_VERSION +ENV OS_NAME RHEL + +RUN microdnf --setopt=install_weak_deps=0 --setopt=tsflags=nodocs \ + install -y java-${RANGER_BASE_JAVA_VERSION}-openjdk-devel \ + && microdnf clean all \ + && rpm -q java-${RANGER_BASE_JAVA_VERSION}-openjdk-devel + +ENV JAVA_HOME="/usr/lib/jvm/java-${RANGER_BASE_JAVA_VERSION}" \ + JAVA_VENDOR="openjdk" \ + JAVA_VERSION="${RANGER_BASE_JAVA_VERSION}" \ + JBOSS_CONTAINER_OPENJDK_JDK_MODULE="/opt/jboss/container/openjdk/jdk" + +# Install tzdata, Python, python-requests +RUN microdnf install -y python3 python3-pip bc iputils hostname +RUN microdnf install -y tar procps vim perl +RUN pip3 install apache-ranger + +# Set environment variables +ENV RANGER_HOME /opt/ranger +ENV RANGER_DIST /home/ranger/dist +ENV RANGER_SCRIPTS /home/ranger/scripts +ENV PATH /usr/java/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin + + +# setup groups, users, directories +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 \ + && useradd -g ranger -ms /bin/bash rangerkms \ + && groupadd hadoop \ + && useradd -g hadoop -ms /bin/bash hdfs \ + && useradd -g hadoop -ms /bin/bash yarn \ + && useradd -g hadoop -ms /bin/bash hive \ + && useradd -g hadoop -ms /bin/bash hbase \ + && useradd -g hadoop -ms /bin/bash kafka \ + && mkdir -p /home/ranger/dist \ + && mkdir -p /home/ranger/scripts \ + && chown -R ranger:ranger /home/ranger \ + && mkdir -p /opt/ranger \ + && chown -R ranger:ranger /opt/ranger + +ENTRYPOINT [ "/bin/bash" ] diff --git a/dev-support/ranger-docker/README.md b/dev-support/ranger-docker/README.md index cfbe2dfdaa..5b5a8f99c9 100644 --- a/dev-support/ranger-docker/README.md +++ b/dev-support/ranger-docker/README.md @@ -62,7 +62,11 @@ Docker files in this folder create docker images and run them to build Apache Ra 3. Build the ranger-base image: ~~~ + # ubuntu base image: docker-compose -f docker-compose.ranger-base.yml build --no-cache + # OR + # ubi base image: + docker-compose -f docker-compose.ranger-base-ubi.yml build --no-cache ~~~ 7. To enable file based sync source for usersync execute: ```export ENABLE_FILE_SYNC_SOURCE=true``` diff --git a/dev-support/ranger-docker/docker-compose.ranger-base-ubi.yml b/dev-support/ranger-docker/docker-compose.ranger-base-ubi.yml new file mode 100644 index 0000000000..0c1a6ac5a8 --- /dev/null +++ b/dev-support/ranger-docker/docker-compose.ranger-base-ubi.yml @@ -0,0 +1,19 @@ +version: '3' +services: + ranger-base: + build: + context: . + dockerfile: Dockerfile.ranger-base-ubi + args: + - UBI_VERSION=${UBI_VERSION} + - RANGER_BASE_JAVA_VERSION=${RANGER_BASE_UBI_JAVA_VERSION} + image: ranger-base + container_name: ranger-base + networks: + - ranger + environment: + - RANGER_VERSION + +networks: + ranger: + name: rangernw