#!/bin/sh
# Plain-docker translation of the official standalone_embed.sh (milvus-io/milvus scripts/standalone_embed.sh, read 2026-11-06):
# same image, same env vars, embedded etcd, local storage. Differences: no sudo, ports bound to 127.0.0.1, port 2379 not published.
# Run it from a scratch folder that is NOT in a repo: it creates volumes/, embedEtcd.yaml and user.yaml next to itself.
set -eu
IMG=milvusdb/milvus:v3.0.5
mkdir -p volumes/milvus
cat > embedEtcd.yaml <<'YAML'
listen-client-urls: http://0.0.0.0:2379
advertise-client-urls: http://0.0.0.0:2379
quota-backend-bytes: 4294967296
auto-compaction-mode: revision
auto-compaction-retention: '1000'
YAML
: > user.yaml
# the script's prepare step: give /var/lib/milvus to the image's milvus user
docker run --rm --user 0:0 --network none --read-only --entrypoint /bin/sh \
  -v "$PWD/volumes/milvus:/var/lib/milvus" $IMG \
  -c 'chown -R "$(id -u milvus):$(id -g milvus)" /var/lib/milvus'
docker run -d --name milvus-standalone --security-opt seccomp:unconfined \
  -e ETCD_USE_EMBED=true -e ETCD_DATA_DIR=/var/lib/milvus/etcd \
  -e ETCD_CONFIG_PATH=/milvus/configs/embedEtcd.yaml \
  -e COMMON_STORAGETYPE=local -e DEPLOY_MODE=STANDALONE \
  -v "$PWD/volumes/milvus:/var/lib/milvus" \
  -v "$PWD/embedEtcd.yaml:/milvus/configs/embedEtcd.yaml" \
  -v "$PWD/user.yaml:/milvus/configs/user.yaml" \
  -p 127.0.0.1:19530:19530 -p 127.0.0.1:9091:9091 \
  --health-cmd="curl -f http://localhost:9091/healthz" --health-interval=30s \
  --health-start-period=90s --health-timeout=20s --health-retries=3 \
  $IMG milvus run standalone
# Attu 3.x asks for a login by default. ATTU_AUTH_MODE=none is for a local box on 127.0.0.1 only.
docker run -d --name attu -p 127.0.0.1:8001:3000 -e ATTU_AUTH_MODE=none \
  --add-host host.docker.internal:host-gateway zilliz/attu:v3.0.1
echo "Milvus: 127.0.0.1:19530   Attu: http://127.0.0.1:8001 (connect to host.docker.internal:19530, auth None)"
