Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,5 @@
*
!distribution
!docker/src/main/DockerCompose/start-1c1d.sh
!docker/src/main/ainode-build-data/
!docker/src/main/ainode-entrypoint.sh
20 changes: 20 additions & 0 deletions docker/ReadMe.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,9 @@ e.g.
./do-docker-build.sh -t standalone -v 1.0.0
# for ainode, start from 2.0.5
./do-docker-build.sh -t ainode -v 2.0.5-SNAPSHOT
# for ainode, start from 2.0.8
cd src/main
./build-ainode.sh -v 2.0.8-SNAPSHOT -d /data/ainode
```
Notice:
Make directory of src/main/target and put the zip file downloading from the official download page.
Expand Down Expand Up @@ -91,6 +94,23 @@ Please download `docker-compose-ainode.yml` in `docker/src/main/DockerCompose` f
docker compose -f docker-compose-ainode.yml up -d
```

Start from v2.0.7, run
```shell
docker run -d \
--name iotdb-ainode \
--network host \
-p 10810:10810 \
-p 8080:8080 \
-e AIN_SEED_CONFIG_NODE=127.0.0.1:10710 \
-e AIN_RPC_ADDRESS=127.0.0.1 \
-e AIN_RPC_PORT=10810 \
-e AIN_CLUSTER_INGRESS_ADDRESS=127.0.0.1 \
-e AIN_CLUSTER_INGRESS_PORT=6667 \
-e AIN_CLUSTER_INGRESS_USERNAME=root \
-e AIN_CLUSTER_INGRESS_PASSWORD=root \
apache/iotdb:2.0.7-SNAPSHOT-ainode
```

## Quick start
We provide `docker-compose-cluster-1c1d1a.yml` in `docker/src/main/DockerCompose`. Downloading this yaml file, both standalone and ainode docker first. Subsequently, you can easily obtain a IoTDB cluster, which consists of a ConfigNode, a DataNode and a AINode, in your local machine.

Expand Down
3 changes: 3 additions & 0 deletions docker/src/main/DockerCompose/docker-compose-ainode.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,12 @@ services:
- ain_cluster_ingress_username=root
- ain_cluster_ingress_password=root
- ain_cluster_ingress_time_zone=UTC+8
ports:
- "10810:10810"
volumes:
- ainode-data:/ainode/data
- ./logs/ainode:/ainode/logs
restart: unless-stopped
# - ./lib/ainode:/ainode/lib # Uncomment for rolling upgrade
# Note: Some environments set an extremely high container nofile limit (~2^30 = 1073741824).
# This can make the startup step "Checking whether the ports are already occupied..." appear to hang (lsof slow).
Expand Down
66 changes: 0 additions & 66 deletions docker/src/main/Dockerfile-1.0.0-ainode

This file was deleted.

88 changes: 88 additions & 0 deletions docker/src/main/Dockerfile-2.0.x-ainode
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
#
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you 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.
#

FROM python:3.11-slim-bullseye

# Build argument: Version number (required)
ARG VERSION

# Fail build if VERSION is not provided
RUN if [ -z "$VERSION" ]; then echo "ERROR: VERSION build argument is required" && exit 1; fi

# Set environment variables
ENV IOTDB_HOME=/ainode \
PATH=$PATH:/ainode/sbin \
DEBIAN_FRONTEND=noninteractive

# Install system dependencies
RUN apt-get update && apt-get install -y --no-install-recommends \
unzip \
procps \
netcat-openbsd \
curl \
vim \
tzdata \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*

# Set working directory
WORKDIR /tmp

# Copy and extract the distribution package
# Note: Build context is project root (../../.. relative to this Dockerfile)
COPY distribution/target/apache-iotdb-${VERSION}-ainode-bin.zip /tmp/

# Extract and rename directory
RUN unzip -q apache-iotdb-${VERSION}-ainode-bin.zip \
&& mv apache-iotdb-${VERSION}-ainode-bin /ainode \
&& rm -f apache-iotdb-${VERSION}-ainode-bin.zip \
&& mkdir -p /ainode/logs /ainode/data/ainode

# Copy data directory from build server to image
# The build script copies /data/ainode to docker/src/main/ainode-build-data/ before build
# Note: The trailing slash is important - it copies contents not the directory itself
COPY docker/src/main/ainode-build-data/ /ainode/data/ainode/


# Set directory permissions
RUN chmod -R 755 /ainode/sbin \
&& chmod +x /ainode/sbin/*.sh \
&& chmod -R 777 /ainode/data /ainode/logs

# Health check configuration
HEALTHCHECK --interval=30s --timeout=10s --start-period=60s --retries=3 \
CMD curl -f http://localhost:8080/health || exit 1

# Expose ports
# 10810: AINode RPC port (ain_inference_rpc_port)
# 8080: Health check / management port
EXPOSE 10810 8080

# Copy entrypoint script (relative to project root)
COPY docker/src/main/ainode-entrypoint.sh /ainode/sbin/
RUN chmod +x /ainode/sbin/ainode-entrypoint.sh

# Set working directory
WORKDIR /ainode

# Use entrypoint script as startup command
ENTRYPOINT ["/ainode/sbin/ainode-entrypoint.sh"]

# Default command (can be overridden)
CMD ["start"]
150 changes: 150 additions & 0 deletions docker/src/main/ainode-entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,150 @@
#!/bin/bash
#
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you 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.
#
#
# AINode Docker Entrypoint Script
# Supports configuration via environment variables for iotdb-ainode.properties
#

set -e

IOTDB_HOME="/ainode"
CONF_FILE="${IOTDB_HOME}/conf/iotdb-ainode.properties"

# Logging function
log() {
echo "[$(date +'%Y-%m-%d %H:%M:%S')] $1"
}

# Initialize configuration file
init_config() {
if [ ! -f "${CONF_FILE}" ]; then
log "ERROR: Configuration file not found: ${CONF_FILE}"
exit 1
fi

log "Initializing AINode configuration..."

# Backup original configuration
if [ ! -f "${CONF_FILE}.original" ]; then
cp "${CONF_FILE}" "${CONF_FILE}.original"
fi

# Update configuration based on environment variables
# Cluster configuration
update_config "cluster_name" "${CLUSTER_NAME:-defaultCluster}"
update_config "ain_seed_config_node" "${AIN_SEED_CONFIG_NODE:-127.0.0.1:10710}"

# AINode service configuration
update_config "ain_rpc_address" "${AIN_RPC_ADDRESS:-0.0.0.0}"
update_config "ain_rpc_port" "${AIN_RPC_PORT:-10810}"

# DataNode connection configuration
update_config "ain_cluster_ingress_address" "${AIN_CLUSTER_INGRESS_ADDRESS:-127.0.0.1}"
update_config "ain_cluster_ingress_port" "${AIN_CLUSTER_INGRESS_PORT:-6667}"
update_config "ain_cluster_ingress_username" "${AIN_CLUSTER_INGRESS_USERNAME:-root}"
update_config "ain_cluster_ingress_password" "${AIN_CLUSTER_INGRESS_PASSWORD:-root}"

# Storage paths configuration
update_config "ain_system_dir" "${AIN_SYSTEM_DIR:-data/ainode/system}"
update_config "ain_models_dir" "${AIN_MODELS_DIR:-data/ainode/models}"

# Thrift compression configuration
update_config "ain_thrift_compression_enabled" "${AIN_THRIFT_COMPRESSION_ENABLED:-0}"

log "Configuration initialized successfully"
}

# Update configuration item in properties file
update_config() {
local key=$1
local value=$2

if grep -q "^${key}=" "${CONF_FILE}"; then
# Update existing configuration
sed -i "s|^${key}=.*|${key}=${value}|g" "${CONF_FILE}"
else
# Append new configuration
echo "${key}=${value}" >> "${CONF_FILE}"
fi
}

# Start AINode
start_ainode() {
log "Starting AINode..."

# Check if already running
if [ -f "${IOTDB_HOME}/data/ainode.pid" ]; then
local pid=$(cat "${IOTDB_HOME}/data/ainode.pid")
if ps -p ${pid} > /dev/null 2>&1; then
log "AINode is already running with PID ${pid}"
return 0
fi
fi

# Use exec to replace current process and ensure proper signal handling
exec ${IOTDB_HOME}/sbin/start-ainode.sh
}

# Stop AINode
stop_ainode() {
log "Stopping AINode..."
if [ -f "${IOTDB_HOME}/sbin/stop-ainode.sh" ]; then
${IOTDB_HOME}/sbin/stop-ainode.sh
else
log "Stop script not found"
fi
}

# Handle signals for graceful shutdown
trap stop_ainode SIGTERM SIGINT

# Main logic
case "${1:-start}" in
start)
init_config
start_ainode
;;
stop)
stop_ainode
;;
restart)
stop_ainode
sleep 10
init_config
start_ainode
;;
status)
if [ -f "${IOTDB_HOME}/data/ainode.pid" ]; then
cat "${IOTDB_HOME}/data/ainode.pid"
else
echo "AINode is not running"
exit 1
fi
;;
config)
# Only generate configuration without starting (for debugging)
init_config
cat "${CONF_FILE}"
;;
*)
# Execute other commands directly
exec "$@"
;;
esac
Loading
Loading