This repository has been archived by the owner on Jul 10, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 252
SUBMARINE-341. Add submarine server dockerfile #148
Closed
Closed
Changes from 1 commit
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
#!/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. | ||
|
||
USAGE="Usage: bin/submarine.sh [--config <conf-dir>]" | ||
|
||
if [[ "$1" == "--config" ]]; then | ||
shift | ||
conf_dir="$1" | ||
if [[ ! -d "${conf_dir}" ]]; then | ||
echo "ERROR : ${conf_dir} is not a directory" | ||
echo ${USAGE} | ||
exit 1 | ||
else | ||
export SUBMARINE_CONF_DIR="${conf_dir}" | ||
fi | ||
shift | ||
fi | ||
|
||
if [ -L ${BASH_SOURCE-$0} ]; then | ||
BIN=$(dirname $(readlink "${BASH_SOURCE-$0}")) | ||
else | ||
BIN=$(dirname ${BASH_SOURCE-$0}) | ||
fi | ||
export BIN=$(cd "${BIN}">/dev/null; pwd) | ||
GET_MYSQL_JAR=false | ||
|
||
. "${BIN}/common.sh" | ||
|
||
cd ${BIN}/>/dev/null | ||
|
||
SUBMARINE_SERVER_NAME="Submarine Server" | ||
SUBMARINE_SERVER_LOGFILE="${SUBMARINE_LOG_DIR}/submarine.log" | ||
SUBMARINE_SERVER_MAIN=org.apache.submarine.server.SubmarineServer | ||
JAVA_OPTS+="${SUBMARINE_SERVER_JAVA_OPTS:-""} ${SUBMARINE_SERVER_MEM:-""} -Dsubmarine.log.file=${SUBMARINE_SERVER_LOGFILE}" | ||
|
||
add_jar_in_dir "${BIN}/../lib" | ||
add_jar_in_dir "${BIN}/../lib/submitter" | ||
|
||
if [[ ! -d "${SUBMARINE_LOG_DIR}" ]]; then | ||
echo "Log dir doesn't exist, create ${SUBMARINE_LOG_DIR}" | ||
$(mkdir -p "${SUBMARINE_LOG_DIR}") | ||
fi | ||
|
||
exec $JAVA_RUNNER $JAVA_OPTS -cp ${SUBMARINE_SERVER_CLASSPATH} ${SUBMARINE_SERVER_MAIN} "$@" >> "${SUBMARINE_SERVER_LOGFILE}" 2>&1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
# 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 submarinehub/alpine:3.10 | ||
MAINTAINER Apache Software Foundation <dev@submarine.apache.org> | ||
|
||
# Update apk repositories | ||
RUN echo "http://mirrors.ustc.edu.cn/alpine/v3.10/main" > /etc/apk/repositories | ||
RUN echo "http://mirrors.ustc.edu.cn/alpine/v3.10/community" >> /etc/apk/repositories | ||
|
||
# INSTALL openjdk | ||
RUN apk update && \ | ||
apk add --no-cache openjdk8 tzdata tini && \ | ||
cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime && \ | ||
echo Asia/Shanghai > /etc/timezone && \ | ||
apk del tzdata && \ | ||
rm -rf /tmp/* /var/cache/apk/* | ||
|
||
|
||
ENV JAVA_HOME /usr/lib/jvm/java-1.8-openjdk/jre | ||
|
||
# Install Submarine | ||
ADD ./tmp/submarine-dist-*.tar.gz /opt/ | ||
RUN ln -s /opt/submarine-dist-* "/opt/submarine-current" | ||
RUN mv /opt/mysql-connector-java-*.jar /opt/submarine-current/lib/ | ||
ADD ./tmp/submarine-site.xml "/opt/submarine-current/conf/" | ||
ADD ./tmp/submarine.sh "/opt/submarine-current/bin/" | ||
|
||
WORKDIR /opt/submarine-current | ||
|
||
# Submarine port | ||
EXPOSE 8080 | ||
|
||
ENTRYPOINT ["/sbin/tini", "--"] | ||
|
||
CMD ["/bin/bash", "-c", "/opt/submarine-current/bin/submarine.sh start"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
#!/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. | ||
|
||
set -eo pipefail | ||
|
||
SUBMARINE_VERSION=0.3.0 | ||
SUBMARINE_IMAGE_NAME="apache/submarine:submarine-${SUBMARINE_VERSION}" | ||
|
||
if [ -L ${BASH_SOURCE-$0} ]; then | ||
PWD=$(dirname $(readlink "${BASH_SOURCE-$0}")) | ||
else | ||
PWD=$(dirname ${BASH_SOURCE-$0}) | ||
fi | ||
export CURRENT_PATH=$(cd "${PWD}">/dev/null; pwd) | ||
export SUBMARINE_HOME=${CURRENT_PATH}/../../.. | ||
|
||
if [ ! -d "${SUBMARINE_HOME}/submarine-dist/target" ]; then | ||
mkdir "${SUBMARINE_HOME}/submarine-dist/target" | ||
fi | ||
submarine_dist_exists=$(find -L "${SUBMARINE_HOME}/submarine-dist/target" -name "submarine-dist-${submarine_v}*.tar.gz") | ||
# Build source code if the package doesn't exist. | ||
if [[ -z "${submarine_dist_exists}" ]]; then | ||
# update tony code | ||
if is_empty_dir "${SUBMARINE_HOME}/submodules/tony" ]; then | ||
git submodule update --init --recursive | ||
else | ||
git submodule update --recursive | ||
fi | ||
cd "${SUBMARINE_HOME}" | ||
mvn clean package -DskipTests | ||
fi | ||
|
||
mkdir -p "${CURRENT_PATH}/tmp" | ||
cp ${SUBMARINE_HOME}/submarine-dist/target/submarine-dist-${SUBMARINE_VERSION}*.tar.gz "${CURRENT_PATH}/tmp" | ||
|
||
# Replace the mysql jdbc.url in the submarine-site.xml file with the link name of the submarine container | ||
# `submarine-database` is submarine database container name | ||
cp ${SUBMARINE_HOME}/conf/submarine-site.xml "${CURRENT_PATH}/tmp/" | ||
sed -i ".bak" 's/127.0.0.1:3306/submarine-database:3306/g' "${CURRENT_PATH}/tmp/submarine-site.xml" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks for the patch,@liuxunorg. I change the command to There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done. |
||
|
||
cp ${SUBMARINE_HOME}/bin/submarine.sh "${CURRENT_PATH}/tmp/" | ||
|
||
# build image | ||
cd ${CURRENT_PATH} | ||
echo "Start building the ${SUBMARINE_IMAGE_NAME} docker image ..." | ||
docker build -t ${SUBMARINE_IMAGE_NAME} . | ||
|
||
# clean temp file | ||
rm -rf "${CURRENT_PATH}/tmp" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's better to use
SUBMARINE_VERSION
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.