feat: add dockerfile and modify install.sh (#30242)

* feat: add Dockerfile and modify install.sh

* enh: add a port

* fix: modify addr to 0.0.0.0 from 127.0.0.1 in taosanode.ini
This commit is contained in:
jiajingbin 2025-03-18 17:35:12 +08:00 committed by GitHub
parent 2d57795e70
commit f62ef250fd
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
7 changed files with 73 additions and 4 deletions

View File

@ -7,7 +7,7 @@
env = LC_ALL = en_US.UTF-8 env = LC_ALL = en_US.UTF-8
# ip:port # ip:port
http = 127.0.0.1:6090 http = 0.0.0.0:6090
# the local unix socket file than communicate to Nginx # the local unix socket file than communicate to Nginx
#socket = 127.0.0.1:8001 #socket = 127.0.0.1:8001
@ -62,7 +62,7 @@ reload-mercy = 10
logto = /var/log/taos/taosanode/taosanode.log logto = /var/log/taos/taosanode/taosanode.log
# wWSGI monitor port # wWSGI monitor port
stats = 127.0.0.1:8387 stats = 0.0.0.0:8387
# python virtual environment directory # python virtual environment directory
virtualenv = /usr/local/taos/taosanode/venv/ virtualenv = /usr/local/taos/taosanode/venv/

View File

@ -0,0 +1,24 @@
FROM python:3.10-slim AS builder
ENV VIRTUAL_ENV=/var/lib/taos/taosanode/venv
ENV PATH="$VIRTUAL_ENV/bin:$PATH"
RUN apt-get -o Acquire::Check-Valid-Until=false -o Acquire::Check-Date=false update -y && \
apt-get install -y --no-install-recommends gcc libc-dev procps && \
apt-get clean && \
rm -rf /var/lib/apt/lists/* && \
python3.10 -m venv /var/lib/taos/taosanode/venv && \
pip install --upgrade pip && \
pip install --ignore-installed blinker && \
pip install numpy==1.26.4 pandas==1.5.0 scikit-learn outlier_utils statsmodels pyculiarity pmdarima flask matplotlib uwsgi -i https://pypi.tuna.tsinghua.edu.cn/simple && \
pip install torch --index-url https://download.pytorch.org/whl/cpu && \
pip install --upgrade keras -i https://pypi.tuna.tsinghua.edu.cn/simple
FROM python:3.10-slim
COPY --from=builder /var/lib/taos/taosanode/venv /var/lib/taos/taosanode/venv
RUN apt-get update -y && \
apt-get install -y --no-install-recommends procps && \
apt-get clean && \
rm -rf /var/lib/apt/lists/*
ENV VIRTUAL_ENV=/var/lib/taos/taosanode/venv
ENV PATH="$VIRTUAL_ENV/bin:$PATH"

View File

@ -0,0 +1 @@
docker build -t "tdgpt_env:1.0" .

View File

@ -0,0 +1,11 @@
FROM tdgpt_env:1.0
WORKDIR /apps
ENV DEBIAN_FRONTEND=noninteractive
ARG pkgFile
ARG dirName
ADD ${pkgFile} /apps
RUN cd ${dirName}/ && /bin/bash install.sh -e no && cd .. && rm -rf ${dirName}
COPY entrypoint.sh /usr/local/bin/entrypoint.sh
RUN chmod +x /usr/local/bin/entrypoint.sh
EXPOSE 6090 8387
ENTRYPOINT ["/usr/local/bin/entrypoint.sh"]

View File

@ -0,0 +1 @@
docker build --build-arg pkgFile=TDengine-anode-3.3.6.0-Linux-x64.tar.gz --build-arg dirName=TDengine-anode-3.3.6.0 -t "tdgpt-ce:3.3.6.0" .

View File

@ -0,0 +1,20 @@
#!/bin/bash
export PATH="/usr/local/taos/taosanode/venv/bin:$PATH"
export LANG=en_US.UTF-8
export LC_CTYPE=en_US.UTF-8
export LC_ALL=en_US.UTF-8
CONFIG_FILE="/usr/local/taos/taosanode/cfg/taosanode.ini"
if [ ! -f "$CONFIG_FILE" ]; then
echo "Error: Configuration file $CONFIG_FILE not found!"
exit 1
fi
echo "Starting uWSGI with config: $CONFIG_FILE"
exec /usr/local/taos/taosanode/venv/bin/uwsgi --ini "$CONFIG_FILE"
if [ $? -ne 0 ]; then
echo "uWSGI failed to start. Exiting..."
exit 1
fi

View File

@ -482,6 +482,14 @@ function install_service_on_systemd() {
${csudo}systemctl daemon-reload ${csudo}systemctl daemon-reload
} }
function is_container() {
if [[ -f /.dockerenv ]] || grep -q "docker\|kubepods" /proc/1/cgroup || [[ -n "$KUBERNETES_SERVICE_HOST" || "$container" == "docker" ]]; then
return 0 # container env
else
return 1 # not container env
fi
}
function install_service() { function install_service() {
if ((${service_mod} == 0)); then if ((${service_mod} == 0)); then
install_service_on_systemd $1 install_service_on_systemd $1
@ -615,7 +623,9 @@ function updateProduct() {
if [ -z $1 ]; then if [ -z $1 ]; then
install_bin install_bin
install_services if ! is_container; then
install_services
fi
echo echo
echo -e "${GREEN_DARK}To configure ${productName} ${NC}\t\t: edit ${global_conf_dir}/${configFile}" echo -e "${GREEN_DARK}To configure ${productName} ${NC}\t\t: edit ${global_conf_dir}/${configFile}"
@ -659,7 +669,9 @@ function installProduct() {
install_module install_module
install_bin_and_lib install_bin_and_lib
install_services if ! is_container; then
install_services
fi
echo echo
echo -e "\033[44;32;1m${productName} is installed successfully!${NC}" echo -e "\033[44;32;1m${productName} is installed successfully!${NC}"