Skip to content

Commit

Permalink
RANGER-3746: Add ranger base image on ubi9-minimal with build and spa…
Browse files Browse the repository at this point in the history
…ce optimizations
  • Loading branch information
abhishek-kumar committed Oct 28, 2023
1 parent de049b9 commit 02f5f35
Show file tree
Hide file tree
Showing 6 changed files with 103 additions and 4 deletions.
12 changes: 10 additions & 2 deletions dev-support/ranger-docker/.env
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
6 changes: 4 additions & 2 deletions dev-support/ranger-docker/Dockerfile.ranger
Original file line number Diff line number Diff line change
Expand Up @@ -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/
Expand Down
1 change: 1 addition & 0 deletions dev-support/ranger-docker/Dockerfile.ranger-base
Original file line number Diff line number Diff line change
Expand Up @@ -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 && \
Expand Down
65 changes: 65 additions & 0 deletions dev-support/ranger-docker/Dockerfile.ranger-base-ubi
Original file line number Diff line number Diff line change
@@ -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" ]
4 changes: 4 additions & 0 deletions dev-support/ranger-docker/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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```
Expand Down
19 changes: 19 additions & 0 deletions dev-support/ranger-docker/docker-compose.ranger-base-ubi.yml
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit 02f5f35

Please sign in to comment.