Skip to content

Commit

Permalink
RANGER-4734: Docker setup updated to build Trino plugin package - #2
Browse files Browse the repository at this point in the history
  • Loading branch information
mneethiraj committed Mar 12, 2024
1 parent 02c0748 commit c6842bc
Show file tree
Hide file tree
Showing 8 changed files with 91 additions and 40 deletions.
6 changes: 5 additions & 1 deletion dev-support/ranger-docker/.env
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@ BRANCH=master
PROFILE=
BUILD_OPTS=

# To build Trino plugins package, use following PROFILE and BUILD_OPTS
PROFILE=ranger-jdk11,!all,!linux
BUILD_OPTS=-pl !unixauthnative

# Java version for RangerBase image.
# This image gets used as base docker image for all images.
# Valid values: 8, 11, 17
Expand All @@ -13,7 +17,7 @@ RANGER_BASE_JAVA_VERSION=8
# Java version to use to build Apache Ranger
# Valid values: 8, 11, 17
# Trino builds on jdk 11 and above
RANGER_BUILD_JAVA_VERSION=8
RANGER_BUILD_JAVA_VERSION=11

# Java version to use to run Ranger Admin server
# Valid values: 8, 11, 17
Expand Down
32 changes: 18 additions & 14 deletions dev-support/ranger-docker/Dockerfile.ranger-trino
Original file line number Diff line number Diff line change
Expand Up @@ -34,37 +34,41 @@ ARG TRINO_VERSION
ARG TRINO_PLUGIN_VERSION
ENV PLUGIN_DIR=ranger-${TRINO_PLUGIN_VERSION}-trino-plugin

RUN mkdir -p /home/ranger/dist
RUN mkdir -p /opt/ranger
RUN mkdir -p /home/ranger/scripts
RUN groupadd ranger
RUN useradd -g ranger -ms /bin/bash ranger
RUN usermod -a -G ranger trino
RUN chown -R ranger:ranger /home/ranger
RUN chown -R ranger:ranger /opt/ranger
RUN mkdir -p /home/ranger/dist /home/ranger/scripts /opt/ranger

COPY ./dist/version /home/ranger/dist
COPY ./dist/ranger-${TRINO_PLUGIN_VERSION}-trino-plugin.tar.gz /home/ranger/dist
COPY ./scripts/ranger-trino.sh /home/ranger/scripts
COPY ./scripts/ranger-trino-setup.sh /home/ranger/scripts
COPY ./scripts/ranger-trino-plugin-install.properties /home/ranger/scripts

RUN if [ $TRINO_VERSION -ge 370 ] && [ $TRINO_VERSION -lt 390 ] || [ $TRINO_VERSION -eq 392 ]; then\
dnf install -y initscripts;\
dnf install -y openssh-clients;\
dnf install -y openssh-server;\
dnf install -y sudo;\
elif [ $TRINO_VERSION -ge 432 ]; then\
microdnf install -y gzip;\
microdnf install -y initscripts;\
microdnf install -y openssh-clients;\
microdnf install -y openssh-server;\
microdnf install -y sudo;\
else\
apt-get update; DEBIAN_FRONTEND="noninteractive" apt-get -y install ssh;\
apt-get update; DEBIAN_FRONTEND="noninteractive" apt-get -y install ssh sudo;\
fi

RUN tar xvfz /home/ranger/dist/${PLUGIN_DIR}.tar.gz --directory=/opt/ranger
RUN ln -s /opt/ranger/${PLUGIN_DIR} /opt/ranger/ranger-trino-plugin
RUN rm -f /home/ranger/dist/${PLUGIN_DIR}.tar.gz
RUN cp -f /home/ranger/scripts/ranger-trino-plugin-install.properties /opt/ranger/ranger-trino-plugin/install.properties
RUN chmod 744 /home/ranger/scripts/ranger-trino.sh
RUN tar xvfz /home/ranger/dist/${PLUGIN_DIR}.tar.gz --directory=/opt/ranger && \
ln -s /opt/ranger/${PLUGIN_DIR} /opt/ranger/ranger-trino-plugin && \
rm -f /home/ranger/dist/${PLUGIN_DIR}.tar.gz && \
cp -f /home/ranger/scripts/ranger-trino-plugin-install.properties /opt/ranger/ranger-trino-plugin/install.properties && \
chown -R trino:trino /home/ranger /opt/ranger && \
chown root:root /home/ranger/scripts /home/ranger/scripts/ranger-trino-setup.sh && \
chmod 744 /home/ranger/scripts/ranger-trino-setup.sh /home/ranger/scripts/ranger-trino.sh

# enable trino user to execute setup script as root
RUN echo "trino ALL=(ALL) NOPASSWD:/home/ranger/scripts/ranger-trino-setup.sh" > /etc/sudoers.d/trino


USER trino

ENTRYPOINT ["/home/ranger/scripts/ranger-trino.sh"]
1 change: 1 addition & 0 deletions dev-support/ranger-docker/docker-compose.ranger-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ services:
environment:
- BRANCH
- BUILD_HOST_SRC
- BUILD_OPTS
- PROFILE
- GIT_URL
- RANGER_VERSION
Expand Down
1 change: 0 additions & 1 deletion dev-support/ranger-docker/docker-compose.ranger-trino.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ services:
- TRINO_VERSION=${TRINO_VERSION}
image: ranger-trino
hostname: ranger-trino
user: root
container_name: ranger-trino
stdin_open: true
tty: true
Expand Down
2 changes: 1 addition & 1 deletion dev-support/ranger-docker/scripts/ranger-build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ else
done
fi

mvn ${ARG_PROFILES} ${ARG_SKIPTESTS} -DskipDocs ${BUILD_OPTS} clean package
mvn ${ARG_PROFILES} ${BUILD_OPTS} ${ARG_SKIPTESTS} -DskipDocs clean package

mv -f target/version /home/ranger/dist/
mv -f target/ranger-* /home/ranger/dist/
Original file line number Diff line number Diff line change
Expand Up @@ -158,12 +158,12 @@ SSL_TRUSTSTORE_PASSWORD=changeit
# Custom component user
# CUSTOM_COMPONENT_USER=<custom-user>
# keep blank if component user is default
CUSTOM_USER=root
CUSTOM_USER=


#
# Custom component group
# CUSTOM_COMPONENT_GROUP=<custom-group>
# keep blank if component group is default
CUSTOM_GROUP=root
CUSTOM_GROUP=
XAAUDIT.SUMMARY.ENABLE=false
44 changes: 44 additions & 0 deletions dev-support/ranger-docker/scripts/ranger-trino-setup.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
#!/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.


source /tmp/trino-setup-env.sh

TRINO_PLUGIN_HOME=/opt/ranger/ranger-trino-plugin

ssh-keygen -A
/usr/sbin/sshd

if [ ! -e ${TRINO_PLUGIN_HOME}/.setupDone ]
then
su -c "ssh-keygen -t rsa -P '' -f ~/.ssh/id_rsa" trino
su -c "cat ~/.ssh/id_rsa.pub >> ~/.ssh/authorized_keys" trino
su -c "chmod 0600 ~/.ssh/authorized_keys" trino

cat <<EOF > /etc/ssh/ssh_config
Host *
StrictHostKeyChecking no
UserKnownHostsFile=/dev/null
EOF

cd ${TRINO_PLUGIN_HOME} || exit
./enable-trino-plugin.sh

touch ${TRINO_PLUGIN_HOME}/.setupDone
echo "Ranger Trino Plugin Installation is complete!"
fi
41 changes: 20 additions & 21 deletions dev-support/ranger-docker/scripts/ranger-trino.sh
Original file line number Diff line number Diff line change
@@ -1,26 +1,25 @@
#!/bin/bash

ssh-keygen -A
/usr/sbin/sshd

if [ ! -e "${TRINO_HOME}"/.setupDone ]
then
su -c "ssh-keygen -t rsa -P '' -f ~/.ssh/id_rsa" trino
su -c "cat ~/.ssh/id_rsa.pub >> ~/.ssh/authorized_keys" trino
su -c "chmod 0600 ~/.ssh/authorized_keys" trino

cat <<EOF > /etc/ssh/ssh_config
Host *
StrictHostKeyChecking no
UserKnownHostsFile=/dev/null
EOF

cd /opt/ranger/ranger-trino-plugin || exit
./enable-trino-plugin.sh

touch "${TRINO_HOME}"/.setupDone
echo "Ranger Trino Plugin Installation is complete!"
fi
# 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.


echo "export JAVA_HOME=${JAVA_HOME}" >> /tmp/trino-setup-env.sh

sudo /home/ranger/scripts/ranger-trino-setup.sh

/usr/lib/trino/bin/run-trino

Expand Down

0 comments on commit c6842bc

Please sign in to comment.