This is an automated email from the ASF dual-hosted git repository.

sneethir pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/ranger.git

commit dbca7795c13290027b00c5d410fa6843ddbec172
Author: Selvamohan Neethiraj <[email protected]>
AuthorDate: Wed Dec 14 23:44:52 2022 -0500

    RANGER-4017: running ranger in few mins using docker
---
 README.txt       |  31 ++++++++-
 ranger_in_docker | 188 +++++++++++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 217 insertions(+), 2 deletions(-)

diff --git a/README.txt b/README.txt
index fce972ab1..6a4daa5ff 100644
--- a/README.txt
+++ b/README.txt
@@ -22,8 +22,35 @@ Apache Ranger is currently NOT setup to use pull requests to 
take in the changes
 Please use the apache review board to submit your code changes for review and 
commit. https://reviews.apache.org
 Also create a jira to go along with the review and mention it in the review 
board review. https://issues.apache.org/jira/browse/RANGER
 
-Build Process
-=============
+
+===============================================================================================
+Running the entire Apache Ranger (and its related technology stack) in Docker 
(SANDBOX INSTALL)
+===============================================================================================
+
+1. Check out the code from GIT repository (for Apache Ranger) 
[https://github.com/apache/ranger.git]
+
+2. Ensure that docker & docker-compose is installed and running on your system.
+
+3. Ensure that JDK 1.8+ is installed on your system.
+
+4. Ensure that Apache Maven is installed on your system.
+
+5. Run the following command to build & run Apache RANGER from Docker
+
+       $ ./ranger_in_docker up
+
+6. After successful completion of the above command, you should be able to 
view Ranger Admin Console by using URL:
+       
+       http://<hostname-of-system>:6080/
+
+       UserName: admin
+       Password: rangerR0cks!
+
+===============================================================================================
+
+
+Regular Build Process
+=======================
 
 1. Check out the code from GIT repository
 
diff --git a/ranger_in_docker b/ranger_in_docker
new file mode 100755
index 000000000..9fecb3892
--- /dev/null
+++ b/ranger_in_docker
@@ -0,0 +1,188 @@
+#!/bin/bash
+
+# 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.
+
+#
+# This script provides an reference implementation of what is specified in
+# ./dev-support/ranger-docker/README.md 
+#
+# Using this command, you should be able to build and run Apache Ranger
+# within few minites (in a docker container)
+#
+# Pre Request:
+#
+# Java version  1.8.*
+# Maven version 3.0+
+# Docker Installation (docker, docker-compose, ...)
+#
+# By default, the directory where the script exists - is assumed to be 
RANGER_HOME.
+# However, you can define RANGER_HOME to be a different directory before 
running this script via exported env variable.
+#
+# Also, you can force rebuild of ranger image by setting RANGER_REBUILD=1
+# By default, the script will check if a ranger image does not exists and will 
do ranger build and docker image build.
+#
+
+if [ $# -eq 1 ]
+then
+       DOCKER_ACTION="$1"
+else
+       DOCKER_ACTION=""
+fi
+
+if [ "${DOCKER_ACTION}" != "up" -a "${DOCKER_ACTION}" != "down" ]
+then
+       echo "ERROR: Invalid argument [${DOCKER_ACTION}]"
+       echo "USAGE: $0 <up|down>"
+       exit 1
+fi
+
+docker -v > /dev/null 2>&1
+
+if [ $? -ne 0 ]
+then
+       echo "ERROR: You must have a valid DOCKER installed on your system to 
do a docker build. (error running docker command)"
+       exit 1
+fi
+
+docker-compose --version > /dev/null 2>&1
+
+if [ $? -ne 0 ]
+then
+       echo "ERROR: You must have a valid DOCKER installed on your system to 
do a docker build. (error running docker-compose command)"
+       exit 1
+fi
+
+mvn --version > /dev/null 2>&1
+
+if [ $? -ne 0 ]
+then
+       echo "ERROR: You must have MAVEN tool installed on your system to do a 
ranger build. (error running mvn command)"
+       exit 1
+fi
+
+if [ -z "${RANGER_HOME}" ]
+then
+       rhd=`dirname $0`
+       RANGER_HOME=$(cd ${rhd}; pwd)
+fi
+
+if [ ! -d "${RANGER_HOME}" ]
+then
+       echo "ERROR: directory RANGER_HOME=[${RANGER_HOME}] does not exists."
+       exit 1
+fi
+
+RD_HOME=${RANGER_HOME}/dev-support/ranger-docker
+ENV_FILE=${RD_HOME}/.env
+
+cd ${RANGER_HOME}
+
+if [ ! -f ${ENV_FILE} ]
+then
+       echo "ERROR: Environment file [${ENV_FILE}] is missing."
+       exit 1
+fi
+
+build_ranger=0
+build_base_image=0
+
+cd ${RD_HOME}
+
+if [ ${DOCKER_ACTION} == "up" ]
+then
+
+       DOCKER_COMPOSE_FLAGS="-d"
+
+       chmod +x download-archives.sh && ./download-archives.sh
+       
+       if [ -z "${RANGER_REBUILD}" ]
+       then
+               noOfFiles=`ls -l ${RD_HOME}/dist/*.tar.gz 2> /dev/null| wc -l | 
awk '{ print $1 }'`
+               if [ ${noOfFiles} -lt 20 ]
+               then
+                       #echo "Found only [${noOfFiles}] RANGER tar files. 
Enabling RANGER BUILD."
+                       build_ranger=1
+                       build_base_image=1
+               #else
+                       #echo "Found [${noOfFiles}] RANGER tar files. Skipping 
RANGER BUILD. To Force RANGER BUILD, please set RANGER_REBUILD=1 before running 
this script."
+               fi
+       else
+               #echo "Found [RANGER_REBUILD as ${RANGER_REBUILD}]. Enabling 
RANGER BUILD."
+               build_base_image=1
+               build_ranger=1
+       fi
+       
+       if [ ${build_ranger} -eq 1 ]
+       then
+               cd ${RANGER_HOME} 
+               mvn clean package -DskipTests
+               if [ $? -ne 0 ]
+               then
+                       echo "ERROR: Unable to complete RANGER build. Exiting 
...."
+                       exit 1
+               fi
+               cp target/ranger-* ${RD_HOME}/dist
+               cp target/version ${RD_HOME}/dist 
+       fi
+       
+       cd ${RD_HOME}
+       
+       if [ ${build_base_image} -eq 0 ]
+       then
+               docker images ranger-base:latest 2> /dev/null  | grep 
ranger-base  > /dev/null 2>&1
+               if [ $? -ne 0 ]
+               then
+                       build_base_image=1
+               fi
+       fi
+       
+       if [ ${build_base_image} -eq 1 ]
+       then
+               echo "+ docker-compose -f docker-compose.ranger-base.yml build 
--no-cache"
+               docker-compose -f docker-compose.ranger-base.yml build 
--no-cache
+       fi
+fi
+
+export RANGER_DB_TYPE=postgres
+
+docker-compose -f docker-compose.ranger-base.yml \
+                               -f docker-compose.ranger.yml \
+                               -f docker-compose.ranger-${RANGER_DB_TYPE}.yml \
+                               -f docker-compose.ranger-usersync.yml \
+                               -f docker-compose.ranger-tagsync.yml \
+                               -f docker-compose.ranger-hadoop.yml \
+                               -f docker-compose.ranger-hbase.yml \
+                               -f docker-compose.ranger-kafka.yml \
+                               -f docker-compose.ranger-hive.yml \
+                               -f docker-compose.ranger-knox.yml 
${DOCKER_ACTION} ${DOCKER_COMPOSE_FLAGS}
+
+echo
+echo "################### LIST OF DOCKER PROCESSES EXPOSING PORTS 
#####################"
+echo
+docker container ls --format "table {{.Names}}\t{{.Ports}}" -a | grep ranger | 
\
+               grep -v '^$' | awk '{ for(i = 2 ; i <= NF; i++) { print $1, $i 
} }' | \
+               grep  -- '->' | sed -e 's:,::g' | awk '{ s = $2 ; split(s,a, 
"->") ; f = split(a[1],b,":");  print $1, b[f] }' | \
+               sort  | uniq | awk '{ printf("SERVICE: %25s ExposedPort: 
%10s\n", $1, $2 ) ; }'
+echo
+echo 
"###################################################################################"
+echo
+if [ "${DOCKER_ACTION}" == "up" ]
+then
+       echo
+       echo "Now, You can run  access RANGER portal via http://localhost:6080 
(admin/rangerR0cks!)"
+       echo
+fi

Reply via email to