Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ZEPPELIN-6113] Write a Dockerfile for mongodb interpreter image build #4853

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
59 changes: 59 additions & 0 deletions mongodb/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
#
# 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,mongodb -DskipTests


FROM openjdk:11

RUN apt-get update && \
apt-get install -y wget gnupg && \
wget -qO- https://www.mongodb.org/static/pgp/server-7.0.asc | tee /etc/apt/trusted.gpg.d/mongodb-server-7.0.asc

RUN echo "deb [ arch=amd64,arm64 ] https://repo.mongodb.org/apt/ubuntu focal/mongodb-org/7.0 multiverse" | tee /etc/apt/sources.list.d/mongodb-org-7.0.list

RUN apt-get update && \
apt-get install -y mongodb-mongosh && \
apt-get clean && rm -rf /var/lib/apt/lists/*

COPY --from=builder /zeppelin/bin /zeppelin/bin/
COPY --from=builder /zeppelin/conf /zeppelin/conf
COPY --from=builder /zeppelin/interpreter/mongodb /zeppelin/interpreter/mongodb
COPY --from=builder /zeppelin/zeppelin-interpreter-shaded/target /zeppelin/zeppelin-interpreter-shaded/target

WORKDIR /zeppelin

ENV MONGO_DB_INTERPRETER_PORT=8083

RUN chmod +x ./bin/interpreter.sh

CMD ./bin/interpreter.sh \
-d ./interpreter/mongodb \
-c host.docker.internal \
-p "${INTERPRETER_EVENT_SERVER_PORT}" \
-r "${MONGO_DB_INTERPRETER_PORT}:${MONGO_DB_INTERPRETER_PORT}" \
-i mongodb-shared_process \
-l ./local-repo \
-g mongodb
36 changes: 35 additions & 1 deletion mongodb/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,40 @@ MongoDB interpreter for Apache Zeppelin. Thanksgiving to [bbonnin/zeppelin-mongo
I found bbonnin's mongodb interpreter was not working with newest zeppelin version, it has not been maintained for a long time.
so I forked this for those people who want to use mongodb in zeppelin.

### Technical overview
## Technical overview
it use mongo shell to execute scripts.All you need to do is to configure mongodb interpreter,
and then study mongo aggregate functions.

## How to run the interpreter with docker
You can run the mongodb interpreter as a standalone docker container.

### Step 1. Specify the configuration for the mongodb interpreter
* NOTE: Your mongodb properties should be configured using the host environment settings, such as the URL, username, and password.
```bash
# conf/interpreter.json

"mongodb": {
...
"option":
} {
"remote": true,
"port": {INTERPRETER_PROCESS_PORT_IN_HOST},
"isExistingProcess": true,
"host": "localhost",
...
}
````

### Step 2. Build and run the mongodb 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 ./mongodb/Dockerfile -t mongodb-interpreter .

zeppelin $ docker run -p {INTERPRETER_PROCESS_PORT_IN_HOST}:8083 \
-e INTERPRETER_EVENT_SERVER_PORT={INTERPRETER_EVENT_SERVER_PORT} \
mongodb-interpreter
```
Loading