From 6ad5baa5b31c50bb28b61a9c14d215baa28ab883 Mon Sep 17 00:00:00 2001 From: SeungYoung Oh Date: Sun, 8 Sep 2024 14:05:37 +0900 Subject: [PATCH] [ZEPPELIN-6048] Write a Dockerfile for jdbc interpreter image build (#4794) * refactor: Reformat shell interpreter command in Dockerfile * docs: Fix capitalization in shell interpreter README * feat: Write a Dockerfile for jdbc interpreter image build --- jdbc/Dockerfile | 50 ++++++++++++++++++++++++++++++++++++++++++++++++ jdbc/README.md | 36 ++++++++++++++++++++++++++++++++++ shell/Dockerfile | 9 ++++++++- shell/README.md | 4 ++-- 4 files changed, 96 insertions(+), 3 deletions(-) create mode 100644 jdbc/Dockerfile create mode 100644 jdbc/README.md diff --git a/jdbc/Dockerfile b/jdbc/Dockerfile new file mode 100644 index 00000000000..a8865e87389 --- /dev/null +++ b/jdbc/Dockerfile @@ -0,0 +1,50 @@ +# +# 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. +# + +FROM openjdk:11 as builder + +COPY . /zeppelin/ + +WORKDIR /zeppelin + +RUN chmod +x ./mvnw + +RUN ./mvnw clean package -am -pl zeppelin-interpreter-shaded,zeppelin-interpreter,jdbc -DskipTests + + +FROM openjdk:11 + +COPY --from=builder /zeppelin/bin /zeppelin/bin/ +COPY --from=builder /zeppelin/conf /zeppelin/conf + +COPY --from=builder /zeppelin/interpreter/jdbc /zeppelin/interpreter/jdbc +COPY --from=builder /zeppelin/zeppelin-interpreter-shaded/target /zeppelin/zeppelin-interpreter-shaded/target + +WORKDIR /zeppelin + +ENV JDBC_INTERPRETER_PORT=8082 + +RUN chmod +x ./bin/interpreter.sh + +CMD ["./bin/interpreter.sh", \ + "-d", "./interpreter/jdbc", \ + "-c", "host.docker.internal", \ + "-p", "${INTERPRETER_EVENT_SERVER_PORT}", \ + "-r", "${JDBC_INTERPRETER_PORT}:${JDBC_INTERPRETER_PORT}", \ + "-i", "jdbc-shared_process", \ + "-l", "./local-repo", \ + "-g", "jdbc"] diff --git a/jdbc/README.md b/jdbc/README.md new file mode 100644 index 00000000000..2223336d71e --- /dev/null +++ b/jdbc/README.md @@ -0,0 +1,36 @@ +## Overview +Jdbc interpreter for Apache Zeppelin + +## Run the interpreter with docker +You can run the jdbc interpreter as a standalone docker container. + +### Step 1. Specify the configuration for the jdbc interpreter +* NOTE: Your jdbc properties should be configured using the host environment settings, such as the URL, username, and password. +```bash + # conf/interpreter.json + + "jdbc": { + ... + "option": + } { + "remote": true, + "port": {INTERPRETER_PROCESS_PORT_IN_HOST}, + "isExistingProcess": true, + "host": "localhost", + ... + } +```` + +### Step 2. Build and run the jdbc interpreter +```bash +zeppelin $ ./mvnw clean install -DskipTests + +zeppelin $ ./bin/zeppelin-daemon.sh start # start zeppelin server. +# check the port of the interpreter event server. you can find it by looking for the log that starts with "InterpreterEventServer is starting at" + +zeppelin $ docker build -f ./jdbc/Dockerfile -t jdbc-interpreter . + +zeppelin $ docker run -p {INTERPRETER_PROCESS_PORT_IN_HOST}:8082 \ + -e INTERPRETER_EVENT_SERVER_PORT={INTERPRETER_EVENT_SERVER_PORT} \ + jdbc-interpreter +``` diff --git a/shell/Dockerfile b/shell/Dockerfile index 6ae95661582..1da36a26338 100644 --- a/shell/Dockerfile +++ b/shell/Dockerfile @@ -40,4 +40,11 @@ ENV SHELL_INTERPRETER_PORT=8081 RUN chmod +x ./bin/interpreter.sh -CMD ./bin/interpreter.sh -d interpreter/sh -c host.docker.internal -p ${INTERPRETER_EVENT_SERVER_PORT} -r ${SHELL_INTERPRETER_PORT}:${SHELL_INTERPRETER_PORT} -i sh-shared_process -l ./local-repo -g sh +CMD ["./bin/interpreter.sh", \ + "-d", "interpreter/sh", \ + "-c", "host.docker.internal", \ + "-p", "${INTERPRETER_EVENT_SERVER_PORT}", \ + "-r", "${SHELL_INTERPRETER_PORT}:${SHELL_INTERPRETER_PORT}", \ + "-i", "sh-shared_process", \ + "-l", "./local-repo", \ + "-g", "sh"] diff --git a/shell/README.md b/shell/README.md index b2f2cfa18be..ce224ea8155 100644 --- a/shell/README.md +++ b/shell/README.md @@ -4,7 +4,7 @@ Shell interpreter for Apache Zeppelin ## Run the interpreter with docker You can run the shell interpreter as a standalone docker container. -### step 1. Specify the configuration for the shell interpreter +### Step 1. Specify the configuration for the shell interpreter ```bash # conf/interpreter.json @@ -20,7 +20,7 @@ You can run the shell interpreter as a standalone docker container. } ```` -### step 2. Build and run the shell interpreter +### Step 2. Build and run the shell interpreter ```bash zeppelin $ ./mvnw clean install -DskipTests