Skip to content

Commit

Permalink
fix Dockerfile
Browse files Browse the repository at this point in the history
Signed-off-by: Sijie Shen <[email protected]>
  • Loading branch information
ds-ssj committed May 16, 2024
1 parent e59437f commit a1d8b98
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 21 deletions.
39 changes: 26 additions & 13 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,3 +1,22 @@
# Copyright 2020-2023 Alibaba Group Holding Limited.
#
# Licensed 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.

# Example:
# docker rm gart0; docker image rm gart
# docker build -t gart .
# docker run -it --name gart0 gart

FROM ubuntu:22.04

# Define build type
Expand All @@ -12,14 +31,12 @@ RUN apt-get update && apt-get install -y \
python3 \
python3-pip \
vim \
wget \
&& rm -rf /var/lib/apt/lists/*
wget

RUN if [ "$build_type" = "All" ]; then \
apt-get update && apt-get install -y \
openssh-server \
&& rm -rf /var/lib/apt/lists/* \
&& mkdir -p /var/run/sshd; \
apt-get install -y openssh-server \
&& touch /workspace/env_script.sh \
&& mkdir -p /var/run/sshd \
&& echo "mkdir -p /root/.ssh && ssh-keygen -q -t rsa -N '' -f /root/.ssh/id_rsa" >> /workspace/env_script.sh \
&& echo "cat /root/.ssh/id_rsa.pub >> /root/.ssh/authorized_keys" >> /workspace/env_script.sh \
&& echo "service ssh start" >> /workspace/env_script.sh; \
Expand All @@ -29,7 +46,7 @@ RUN if [ "$build_type" = "All" ]; then \
RUN if [ "$build_type" = "All" ]; then \
/workspace/gart/scripts/install-psql.sh \
&& /workspace/gart/scripts/install-mysql.sh \
&& echo "service mysql start" >> /workspace/env_script.sh \
&& echo "service mysql start" >> /workspace/env_script.sh; \
fi

WORKDIR /workspace
Expand All @@ -38,8 +55,8 @@ COPY . /workspace/gart
WORKDIR /deps
RUN /workspace/gart/scripts/install-deps.sh /deps $build_type

WORKDIR /workspace
RUN touch env_script.sh
# Complete the installation
RUN rm -rf /var/lib/apt/lists/*

# Find the Kafka directory and write its path to a file
RUN if [ "$build_type" = "All" ]; then \
Expand Down Expand Up @@ -75,7 +92,3 @@ RUN if [ "$build_type" = "All" ]; then \
fi

CMD ["/bin/bash", "-c", ". /workspace/env_script.sh && /bin/bash"]

# Example:
# docker rm gart0; docker image rm gart; docker build -t gart .
# docker run -it --name gart0 gart
30 changes: 22 additions & 8 deletions scripts/gart
Original file line number Diff line number Diff line change
@@ -1,5 +1,19 @@
#!/bin/bash

# Copyright 2020-2023 Alibaba Group Holding Limited.
#
# Licensed 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.

KAFKA_HOME=$KAFKA_HOME
MAXWELL_HOME=$MAXWELL_HOME

Expand Down Expand Up @@ -194,7 +208,7 @@ if [ "$role" != "all" ] && [ "$role" != "capturer" ] && [ "$role" != "converter"
fi

# check environment variables
if [ "$role" == "all" ] || [ "$role" == "capturer" ]; then
if [ "$role" == "all" ] || [ "$role" == "capturer" ]; then
unset=false
if [ -n "$KAFKA_HOME" ]; then
echo " KAFKA_HOME: $KAFKA_HOME"
Expand Down Expand Up @@ -233,7 +247,7 @@ if [ "$role" == "all" ] || [ "$role" == "writer" ]; then
elif [ ! -n "$start_slot" ] && [ -n "$num_slot" ]; then
echo "Please set both start-slot and num-slot"
exit 1
else
else
echo " Run Writer as given slot info"
fi
fi
Expand Down Expand Up @@ -289,7 +303,7 @@ if [ "$role" == "all" ] || [ "$role" == "writer" ]; then
if [ ! -e "$v6d_sock" ] || [ ! -S "$v6d_sock" ]; then
echo "Failed to launch vineyardd"
exit 1
fi
fi
fi
fi

Expand Down Expand Up @@ -355,7 +369,7 @@ if [ "$role" == "all" ] || [ "$role" == "capturer" ]; then

echo "Start Zookeeper and Kafka"
$KAFKA_BIN/zookeeper-server-start.sh -daemon $KAFKA_CONFIG/zookeeper.properties
# pids["Zookeeper"]=$!
# pids["Zookeeper"]=$!
sleep 20
# sleep 20 to avoid https://stackoverflow.com/questions/39759071/error-while-starting-kafka-broker

Expand All @@ -368,15 +382,15 @@ if [ "$role" == "all" ] || [ "$role" == "capturer" ]; then

$KAFKA_BIN/kafka-server-start.sh -daemon $KAFKA_CONFIG/server.properties

# pids["Kafka"]=$!
# pids["Kafka"]=$!
sleep 8
# check if Kafka is started
if grep -q "started" $KAFKA_LOG; then
echo "Kafka log shows successful startup."
else
echo "Kafka log does not indicate successful startup. Please check $KAFKA_LOG for details. Wait for retrying."
fi


# check Kafka failure
for i in {1..3}
Expand Down Expand Up @@ -506,7 +520,7 @@ if [ "$role" == "all" ] || [ "$role" == "converter" ]; then
fi
pids["Converter"]=$!
sleep 2

fi

####################### Writer (VEGITO) #######################
Expand All @@ -529,7 +543,7 @@ if [ "$role" == "writer" ] && [ "$k8s_mode" == "yes" ]; then

echo "Start Writer $subgraph_id"


$WRITER_HOME/vegito --v6d_ipc_socket $v6d_sock \
--etcd_endpoint $etcd_endpoint --meta_prefix $etcd_prefix \
--kafka_broker_list $kafka_server \
Expand Down

0 comments on commit a1d8b98

Please sign in to comment.