diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..1df045f --- /dev/null +++ b/.gitignore @@ -0,0 +1,4 @@ +tags +GPATH +GRTAGS +GTAGS diff --git a/Dockerfile b/Dockerfile index 5e3ff65..23431d3 100644 --- a/Dockerfile +++ b/Dockerfile @@ -19,6 +19,10 @@ ADD ${OPENMLDB_ART:-https://github.com/4paradigm/OpenMLDB/releases/download/v${O RUN if [ -z ${OPENMLDB_ART} ] ; then tar xzf openmldb-*.tar.gz --strip-components=1 && rm -f openmldb-*.tar.gz; fi +VOLUME [ "/var/lib/openmldb/", "/usr/local/lib" ] + +COPY entrypoint.sh . + EXPOSE ${PORT} # NOTE: Must pass necessary flags, or the container will simply exit. @@ -27,4 +31,4 @@ EXPOSE ${PORT} # - --role # - --zk_cluster # - --zk_root_path -ENTRYPOINT ["./bin/openmldb" ] +ENTRYPOINT [ "./entrypoint.sh" ] diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..05a2165 --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,104 @@ +version: "3.8" +name: openmldb_cluster + +volumes: + tablet1-data: + tablet2-data: + tablet3-data: + lib-data: + +services: + openmldb-api: + container_name: openmldb_api + build: . + restart: on-failure + command: + - -- + - "--role=apiserver" + - "--endpoint=openmldb-api:9527" + - "--zk_cluster=openmldb-zk:2181" + - "--zk_root_path=/openmldb" + ports: + - 9527 + depends_on: + - openmldb-ns1 + - openmldb-ns2 + + openmldb-zk: + container_name: openmldb_zk + image: zookeeper:3.4.14 + ports: + - 2181 + + openmldb-ns1: + container_name: openmldb_ns1 + build: . + command: + - -- + - "--role=nameserver" + - "--endpoint=openmldb-ns1:9527" + - "--zk_cluster=openmldb-zk:2181" + - "--zk_root_path=/openmldb" + depends_on: + - openmldb-tablet1 + - openmldb-tablet2 + - openmldb-tablet3 + + openmldb-ns2: + container_name: openmldb_ns2 + build: . + command: + - -- + - "--role=nameserver" + - "--endpoint=openmldb-ns2:9527" + - "--zk_cluster=openmldb-zk:2181" + - "--zk_root_path=/openmldb" + depends_on: + - openmldb-tablet1 + - openmldb-tablet2 + - openmldb-tablet3 + + openmldb-tablet1: + container_name: openmldb_tablet1 + build: . + volumes: + - tablet1-data:/var/lib/openmldb + - lib-data:/usr/local/lib + command: + - -- + - "--role=tablet" + - "--endpoint=openmldb-tablet1:9527" + - "--zk_cluster=openmldb-zk:2181" + - "--zk_root_path=/openmldb" + depends_on: + - openmldb-zk + + openmldb-tablet2: + container_name: openmldb_tablet2 + build: . + volumes: + - tablet2-data:/var/lib/openmldb + - lib-data:/usr/local/lib + command: + - -- + - "--role=tablet" + - "--endpoint=openmldb-tablet2:9527" + - "--zk_cluster=openmldb-zk:2181" + - "--zk_root_path=/openmldb" + depends_on: + - openmldb-zk + + openmldb-tablet3: + container_name: openmldb_tablet3 + build: . + volumes: + - tablet3-data:/var/lib/openmldb + - lib-data:/usr/local/lib + command: + - -- + - "--role=tablet" + - "--endpoint=openmldb-tablet3:9527" + - "--zk_cluster=openmldb-zk:2181" + - "--zk_root_path=/openmldb" + depends_on: + - openmldb-zk diff --git a/entrypoint.sh b/entrypoint.sh new file mode 100755 index 0000000..84803a5 --- /dev/null +++ b/entrypoint.sh @@ -0,0 +1,57 @@ +#!/bin/bash + +set -eE + +cd "$(dirname "$0")" + +PREFIX=/var/lib/openmldb + +#=== FUNCTION ================================================================ +# NAME: usage +# DESCRIPTION: Display usage information. +#=============================================================================== +function usage() { + echo "Usage : $0 [options] [--] [openmldb flags] + + Options: + -p Prefix path for openmldb data, default to '/var/lib/openmldb' + -h|help Display this message" + +} # ---------- end of function usage ---------- + +#----------------------------------------------------------------------- +# Handle command line arguments +#----------------------------------------------------------------------- + +while getopts ":hvp:" opt; do + case $opt in + + h | help) + usage + exit 0 + ;; + + p) PREFIX=$(realpath "$OPTARG") ;; + + *) + echo -e "\n Option does not exist : $OPTARG\n" + usage + exit 1 + ;; + + esac # --- end of case --- +done +shift $((OPTIND - 1)) + +if [ ! -d "$PREFIX" ]; then + mkdir -p "$PREFIX" +fi + +exec ./bin/openmldb \ + --db_root_path="$PREFIX/db" \ + --recycle_bin_root_path="$PREFIX/recycle" \ + --hdd_root_path="$PREFIX/db_hdd" \ + --recycle_bin_hdd_root_path="$PREFIX/recycle_hdd" \ + --ssd_root_path="$PREFIX/db_ssd" \ + --recycle_bin_ssd_root_path="$PREFIX/recycle_ssd" \ + "$@"