feat(docker): dockerization for TDengine 3.0 (#13232)
* feat(docker): dockerization for TDengine 3.0 * feat(docker): dockerization for TDengine 3.0
This commit is contained in:
parent
eabc276ee7
commit
28da2b487c
|
@ -8,25 +8,18 @@ ARG cpuType
|
||||||
RUN echo ${pkgFile} && echo ${dirName}
|
RUN echo ${pkgFile} && echo ${dirName}
|
||||||
|
|
||||||
COPY ${pkgFile} /root/
|
COPY ${pkgFile} /root/
|
||||||
RUN tar -zxf ${pkgFile}
|
ENV TINI_VERSION v0.19.0
|
||||||
WORKDIR /root/
|
ADD https://github.com/krallin/tini/releases/download/${TINI_VERSION}/tini-${cpuType} /tini
|
||||||
RUN cd /root/${dirName}/ && /bin/bash install.sh -e no && cd /root
|
|
||||||
RUN rm /root/${pkgFile}
|
|
||||||
RUN rm -rf /root/${dirName}
|
|
||||||
|
|
||||||
ENV DEBIAN_FRONTEND=noninteractive
|
ENV DEBIAN_FRONTEND=noninteractive
|
||||||
RUN apt-get clean && apt-get update && apt-get install -y locales tzdata netcat && locale-gen en_US.UTF-8
|
WORKDIR /root/
|
||||||
|
RUN tar -zxf ${pkgFile} && cd /root/${dirName}/ && /bin/bash install.sh -e no && cd /root && rm /root/${pkgFile} && rm -rf /root/${dirName} && apt-get update && apt-get install -y locales tzdata netcat && locale-gen en_US.UTF-8 && apt-get clean && rm -rf /var/lib/apt/lists/ && chmod +x /tini
|
||||||
|
|
||||||
ENV LD_LIBRARY_PATH="$LD_LIBRARY_PATH:/usr/lib" \
|
ENV LD_LIBRARY_PATH="$LD_LIBRARY_PATH:/usr/lib" \
|
||||||
LC_CTYPE=en_US.UTF-8 \
|
LC_CTYPE=en_US.UTF-8 \
|
||||||
LANG=en_US.UTF-8 \
|
LANG=en_US.UTF-8 \
|
||||||
LC_ALL=en_US.UTF-8
|
LC_ALL=en_US.UTF-8
|
||||||
|
|
||||||
COPY ./bin/* /usr/bin/
|
COPY ./bin/* /usr/bin/
|
||||||
|
|
||||||
ENV TINI_VERSION v0.19.0
|
|
||||||
RUN bash -c 'echo -e "Downloading tini-${cpuType} ..."'
|
|
||||||
ADD https://github.com/krallin/tini/releases/download/${TINI_VERSION}/tini-${cpuType} /tini
|
|
||||||
RUN chmod +x /tini
|
|
||||||
ENTRYPOINT ["/tini", "--", "/usr/bin/entrypoint.sh"]
|
ENTRYPOINT ["/tini", "--", "/usr/bin/entrypoint.sh"]
|
||||||
CMD ["taosd"]
|
CMD ["taosd"]
|
||||||
VOLUME [ "/var/lib/taos", "/var/log/taos", "/corefile" ]
|
VOLUME [ "/var/lib/taos", "/var/log/taos", "/corefile" ]
|
||||||
|
|
|
@ -11,39 +11,22 @@ DISABLE_ADAPTER=${TAOS_DISABLE_ADAPTER:-0}
|
||||||
unset TAOS_DISABLE_ADAPTER
|
unset TAOS_DISABLE_ADAPTER
|
||||||
|
|
||||||
# to get mnodeEpSet from data dir
|
# to get mnodeEpSet from data dir
|
||||||
DATA_DIR=${TAOS_DATA_DIR:-/var/lib/taos}
|
DATA_DIR=$(taosd -C|grep -E 'dataDir.*(\S+)' -o |head -n1|sed 's/dataDir *//')
|
||||||
|
DATA_DIR=${DATA_DIR:-/var/lib/taos}
|
||||||
|
|
||||||
# append env to custom taos.cfg
|
|
||||||
CFG_DIR=/tmp/taos
|
|
||||||
CFG_FILE=$CFG_DIR/taos.cfg
|
|
||||||
|
|
||||||
mkdir -p $CFG_DIR >/dev/null 2>&1
|
|
||||||
|
|
||||||
[ -f /etc/taos/taos.cfg ] && cat /etc/taos/taos.cfg | grep -E -v "^#|^\s*$" >$CFG_FILE
|
|
||||||
env-to-cfg >>$CFG_FILE
|
|
||||||
|
|
||||||
FQDN=$(cat $CFG_FILE | grep -E -v "^#|^$" | grep fqdn | tail -n1 | sed -E 's/.*fqdn\s+//')
|
|
||||||
|
|
||||||
|
FQDN=$(taosd -C|grep -E 'fqdn.*(\S+)' -o |head -n1|sed 's/fqdn *//')
|
||||||
# ensure the fqdn is resolved as localhost
|
# ensure the fqdn is resolved as localhost
|
||||||
grep "$FQDN" /etc/hosts >/dev/null || echo "127.0.0.1 $FQDN" >>/etc/hosts
|
grep "$FQDN" /etc/hosts >/dev/null || echo "127.0.0.1 $FQDN" >>/etc/hosts
|
||||||
|
FIRSET_EP=$(taosd -C|grep -E 'firstEp.*(\S+)' -o |head -n1|sed 's/firstEp *//')
|
||||||
# parse first ep host and port
|
# parse first ep host and port
|
||||||
FIRST_EP_HOST=${TAOS_FIRST_EP%:*}
|
FIRST_EP_HOST=${FIRSET_EP%:*}
|
||||||
FIRST_EP_PORT=${TAOS_FIRST_EP#*:}
|
FIRST_EP_PORT=${FIRSET_EP#*:}
|
||||||
|
|
||||||
# in case of custom server port
|
# in case of custom server port
|
||||||
SERVER_PORT=$(cat $CFG_FILE | grep -E -v "^#|^$" | grep serverPort | tail -n1 | sed -E 's/.*serverPort\s+//')
|
SERVER_PORT=$(taosd -C|grep -E 'serverPort.*(\S+)' -o |head -n1|sed 's/serverPort *//')
|
||||||
SERVER_PORT=${SERVER_PORT:-6030}
|
SERVER_PORT=${SERVER_PORT:-6030}
|
||||||
|
|
||||||
# for other binaries like interpreters
|
|
||||||
if echo $1 | grep -E "taosd$" - >/dev/null; then
|
|
||||||
true # will run taosd
|
|
||||||
else
|
|
||||||
cp -f $CFG_FILE /etc/taos/taos.cfg || true
|
|
||||||
$@
|
|
||||||
exit $?
|
|
||||||
fi
|
|
||||||
|
|
||||||
set +e
|
set +e
|
||||||
ulimit -c unlimited
|
ulimit -c unlimited
|
||||||
# set core files pattern, maybe failed
|
# set core files pattern, maybe failed
|
||||||
|
@ -62,22 +45,23 @@ fi
|
||||||
# if has mnode ep set or the host is first ep or not for cluster, just start.
|
# if has mnode ep set or the host is first ep or not for cluster, just start.
|
||||||
if [ -f "$DATA_DIR/dnode/mnodeEpSet.json" ] ||
|
if [ -f "$DATA_DIR/dnode/mnodeEpSet.json" ] ||
|
||||||
[ "$TAOS_FQDN" = "$FIRST_EP_HOST" ]; then
|
[ "$TAOS_FQDN" = "$FIRST_EP_HOST" ]; then
|
||||||
$@ -c $CFG_DIR
|
$@
|
||||||
# others will first wait the first ep ready.
|
# others will first wait the first ep ready.
|
||||||
else
|
else
|
||||||
if [ "$TAOS_FIRST_EP" = "" ]; then
|
if [ "$TAOS_FIRST_EP" = "" ]; then
|
||||||
echo "run TDengine with single node."
|
echo "run TDengine with single node."
|
||||||
$@ -c $CFG_DIR
|
$@
|
||||||
exit $?
|
exit $?
|
||||||
fi
|
fi
|
||||||
while true; do
|
while true; do
|
||||||
es=0
|
es=$(taos -h $FIRST_EP_HOST -P $FIRST_EP_PORT --check)
|
||||||
taos -h $FIRST_EP_HOST -P $FIRST_EP_PORT -n startup >/dev/null || es=$?
|
echo ${es}
|
||||||
if [ "$es" -eq 0 ]; then
|
if [ "${es%%:*}" -eq 2 ]; then
|
||||||
|
echo "execute create dnode"
|
||||||
taos -h $FIRST_EP_HOST -P $FIRST_EP_PORT -s "create dnode \"$FQDN:$SERVER_PORT\";"
|
taos -h $FIRST_EP_HOST -P $FIRST_EP_PORT -s "create dnode \"$FQDN:$SERVER_PORT\";"
|
||||||
break
|
break
|
||||||
fi
|
fi
|
||||||
sleep 1s
|
sleep 1s
|
||||||
done
|
done
|
||||||
$@ -c $CFG_DIR
|
$@
|
||||||
fi
|
fi
|
||||||
|
|
|
@ -0,0 +1,8 @@
|
||||||
|
#!/bin/sh
|
||||||
|
es=$(taos --check)
|
||||||
|
code=${es%%:*}
|
||||||
|
if [ "$code" -ne "0" ] && [ "$code" -ne "4" ]; then
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
echo $es
|
||||||
|
exit 1
|
Loading…
Reference in New Issue