Skip to content

Commit

Permalink
polish quick-start
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 15, 2024
1 parent 583562b commit e2d0922
Show file tree
Hide file tree
Showing 10 changed files with 96 additions and 58 deletions.
13 changes: 13 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,19 @@ project(gart)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)

set(DEFAULT_BUILD_TYPE "Release")
if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
message(WARNING "Setting build type to '${DEFAULT_BUILD_TYPE}' as none was specified.")
set(CMAKE_BUILD_TYPE "${DEFAULT_BUILD_TYPE}" CACHE
STRING "Choose the type of build." FORCE
)
set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS
"Debug" "Release" "MinSizeRel" "RelWithDebInfo"
)
else()
message(STATUS "Setting build type to '${CMAKE_BUILD_TYPE}'.")
endif()

### Forbid in-source builds ###
if("${CMAKE_SOURCE_DIR}" STREQUAL "${CMAKE_BINARY_DIR}")
message(FATAL_ERROR "In-source builds are not allowed.")
Expand Down
90 changes: 44 additions & 46 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,23 +4,33 @@ FROM ubuntu:22.04
ARG build_type=All

RUN apt-get update && apt-get install -y \
build-essential \
cmake \
git \
lsb-release \
sudo \
python3 \
python3-pip \
vim \
wget \
&& rm -rf /var/lib/apt/lists/*
build-essential \
cmake \
git \
lsb-release \
sudo \
python3 \
python3-pip \
vim \
wget \
&& rm -rf /var/lib/apt/lists/*

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; \
fi
apt-get update && apt-get install -y \
openssh-server \
&& rm -rf /var/lib/apt/lists/* \
&& 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; \
fi

# Install PostgreSQL and MySQL
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 \
fi

WORKDIR /workspace
COPY . /workspace/gart
Expand All @@ -33,48 +43,36 @@ RUN touch env_script.sh

# Find the Kafka directory and write its path to a file
RUN if [ "$build_type" = "All" ]; then \
set -eux; \
KAFKA_DIR=$(find /deps -maxdepth 1 -type d -name "kafka_*" -print -quit); \
echo "export KAFKA_HOME=${KAFKA_DIR}" >> /etc/profile.d/env_path.sh; \
echo "export MAXWELL_HOME=/deps/maxwell" >> /etc/profile.d/env_path.sh; \
echo "source /etc/profile.d/env_path.sh" >> /workspace/env_script.sh; \
fi
set -eux; \
KAFKA_DIR=$(find /deps -maxdepth 1 -type d -name "kafka_*" -print -quit); \
echo "export KAFKA_HOME=${KAFKA_DIR}" >> /etc/profile.d/env_path.sh; \
echo "export MAXWELL_HOME=/deps/maxwell" >> /etc/profile.d/env_path.sh; \
echo "source /etc/profile.d/env_path.sh" >> /workspace/env_script.sh; \
fi

RUN chmod ugo+x /workspace/env_script.sh

ENV PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION="python"

# Install PostgreSQL
# If you want to install MySQL, use install-mysql.sh instead of install-psql.sh
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 "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; \
fi


RUN mkdir -p /workspace/gart/build && cd /workspace/gart/build
RUN mkdir -p /workspace/gart/build && cd /workspace/gart/build
WORKDIR /workspace/gart/build

RUN bash -c "\
if [ \"$build_type\" = 'All' ]; then \
cmake .. -DADD_GAE_ENGINE=ON && make -j && sudo make install; \
elif [ \"$build_type\" = 'Converter' ]; then \
cmake .. -DADD_PGQL=OFF -DADD_VEGITO=OFF && make -j; \
elif [ \"$build_type\" = 'Writer' ]; then \
cmake .. -DADD_PGQL=OFF -DADD_CONVERTER=OFF && make -j; \
else \
echo 'Invalid build type specified'; exit 1; \
fi \
"
if [ \"$build_type\" = 'All' ]; then \
cmake .. -DADD_GAE_ENGINE=ON && make -j && sudo make install; \
elif [ \"$build_type\" = 'Converter' ]; then \
cmake .. -DADD_PGQL=OFF -DADD_VEGITO=OFF && make -j; \
elif [ \"$build_type\" = 'Writer' ]; then \
cmake .. -DADD_PGQL=OFF -DADD_CONVERTER=OFF && make -j; \
else \
echo 'Invalid build type specified'; exit 1; \
fi \
"

WORKDIR /workspace
RUN if [ "$build_type" = "All" ]; then \
git clone https://github.com/GraphScope/gstest.git; \
fi
git clone https://github.com/GraphScope/gstest.git; \
fi

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

Expand Down
10 changes: 8 additions & 2 deletions apps/networkx/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,12 @@ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=c99")

set(DEFAULT_BUILD_TYPE "Release")
if (NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
message(STATUS "Setting build type to '${DEFAULT_BUILD_TYPE}' as none was specified.")
set(CMAKE_BUILD_TYPE "${DEFAULT_BUILD_TYPE}" CACHE STRING "Choose the type of build." FORCE)
set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS "Debug" "Release" "MinSizeRel" "RelWithDebInfo")
endif ()

set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O3 -g")
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -O0 -g2")
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -O3 -g")
Expand Down Expand Up @@ -125,7 +131,7 @@ set_source_files_properties(${PROTO_SOURCES} PROPERTIES COMPILE_FLAGS -Wno-array
add_executable(gart_networkx_server server/graph_server.cc ${PROTO_SOURCES} ${SOURCES})
target_link_libraries(gart_networkx_server ${GRPC_LIBRARIES} ${Protobuf_LIBRARIES} ${MPI_CXX_LIBRARIES} ${LIBGRAPELITE_LIBRARIES})

add_custom_target(create_pybind_build_dir
add_custom_target(create_pybind_build_dir
COMMAND ${CMAKE_COMMAND} -E make_directory "${CMAKE_CURRENT_SOURCE_DIR}/python_bindings/build"
)

Expand All @@ -144,7 +150,7 @@ add_custom_target(install_python
)


add_custom_target(create_build_dir
add_custom_target(create_build_dir
COMMAND ${CMAKE_COMMAND} -E make_directory "${CMAKE_CURRENT_SOURCE_DIR}/../analytical_engine/build"
)

Expand Down
6 changes: 6 additions & 0 deletions apps/networkx/python_bindings/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,12 @@ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=c99")

set(DEFAULT_BUILD_TYPE "Release")
if (NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
message(STATUS "Setting build type to '${DEFAULT_BUILD_TYPE}' as none was specified.")
set(CMAKE_BUILD_TYPE "${DEFAULT_BUILD_TYPE}" CACHE STRING "Choose the type of build." FORCE)
set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS "Debug" "Release" "MinSizeRel" "RelWithDebInfo")
endif ()

set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O3 -g")
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -O0 -g2")
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -O3 -g")
Expand Down
7 changes: 6 additions & 1 deletion converter/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,11 @@ set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=c99")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O2 -g3")
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -O0 -g2")

if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
set(CMAKE_BUILD_TYPE "Release" CACHE STRING "The default build type is Release" FORCE)
endif()


# ------------------------------------------------------------------------------
# find_libraries
# ------------------------------------------------------------------------------
Expand Down Expand Up @@ -70,4 +75,4 @@ target_include_directories(binlog_convert_maxwell PRIVATE ${RDKAFKA_INCLUDE_DIR}
target_link_libraries(binlog_convert_maxwell ${RDKAFKA_LIBRARIES} ${GFLAGS_LIBRARIES} ${GLOG_LIBRARIES} ${CMAKE_DL_LIBS} ${YAML_CPP_LIBRARIES})

add_executable(json2yaml json2yaml.cc)
target_link_libraries(json2yaml ${YAML_CPP_LIBRARIES})
target_link_libraries(json2yaml ${YAML_CPP_LIBRARIES})
4 changes: 2 additions & 2 deletions docs/documentation/getting-started/quick-start.rst
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ To build the Docker container called ``gart-env`` and enter the container:
:linenos:
$ cd gart
$ docker build . -t gart-env
$ docker run -it gart-env
$ sudo docker build . -t gart-env
$ sudo docker run -it gart-env
After entering the Docker container, build GART:

Expand Down
6 changes: 6 additions & 0 deletions interfaces/grin/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,12 @@ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=c99")

set(DEFAULT_BUILD_TYPE "Release")
if (NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
message(STATUS "Setting build type to '${DEFAULT_BUILD_TYPE}' as none was specified.")
set(CMAKE_BUILD_TYPE "${DEFAULT_BUILD_TYPE}" CACHE STRING "Choose the type of build." FORCE)
set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS "Debug" "Release" "MinSizeRel" "RelWithDebInfo")
endif ()

set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O3 -g")
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -O0 -g2")
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -O3 -g")
Expand Down
13 changes: 8 additions & 5 deletions scripts/install-deps.sh
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,8 @@ if [ "$ROLE" == "All" ] || [ "$ROLE" == "Writer" ]; then
cd ../..
fi

pip3 install pyyaml
# YAML for Python
pip3 install pyyaml libclang

# librdkafka
sudo apt-get install -y librdkafka-dev
Expand All @@ -141,8 +142,13 @@ sudo apt-get install -y librdkafka-dev
sudo apt-get install -y libpq-dev
pip3 install sqlalchemy pymysql psycopg2 etcd3

# Install requirements-dev.txt for docs
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )"
REQUIREMENTS_FILE="$SCRIPT_DIR/../requirements-dev.txt"

pip3 install -r $REQUIREMENTS_FILE

# vineyard
# pip3 install vineyard
sudo apt-get install -y ca-certificates \
doxygen \
libboost-all-dev \
Expand All @@ -162,9 +168,6 @@ sudo apt install -y libarrow-dev=14.0.1-1 \
libgandiva-dev=14.0.1-1 \
libparquet-dev=14.0.1-1


pip3 install libclang

git clone https://github.com/v6d-io/v6d
cd v6d
git submodule update --init
Expand Down
2 changes: 1 addition & 1 deletion scripts/install-mysql.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,4 @@ binlog-do-db=ldbc # change the name to your database
EOT

sudo service mysql restart
sudo service mysql restart
3 changes: 2 additions & 1 deletion scripts/install-psql.sh
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@ max_wal_senders = 1 # larger than 0
EOT

sudo apt-get install postgresql-server-dev-$PSQL_VERSION
# Install the development package for the PostgreSQL Extension:
sudo apt-get install -y postgresql-server-dev-$PSQL_VERSION

sudo /etc/init.d/postgresql restart

Expand Down

0 comments on commit e2d0922

Please sign in to comment.