From e4a635a04ddfc2f42535da31192016f290a60544 Mon Sep 17 00:00:00 2001 From: Chris Lu Date: Mon, 27 Apr 2026 21:21:58 -0700 Subject: [PATCH] feat(docker): default CMD to `mini -dir=/data` for service-container use (#9255) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * feat(docker): default CMD to `mini -dir=/data` for service-container use GitHub Actions service containers cannot pass arguments to the image entrypoint, so `chrislusf/seaweedfs` is currently unusable as a service because it requires a `weed` subcommand. Set a sensible default CMD so the image starts a complete single-process cluster (master, volume, filer, S3 on :8333, admin UI) out of the box, while still being overridable by passing any other subcommand at `docker run` / compose time. Also add a `mini` case to entrypoint.sh so its logs go to stderr, matching the existing master/volume/server cases. Closes #9247 * fix(docker): make `isArgPassed` match `--flag` as well as `-flag` The Go fla9 library accepts both `-flag` and `--flag` syntax, but `isArgPassed` only matched the single-dash form. That meant a user passing `--dir=/foo` to `weed mini` (or `--max=5` to `volume`, `--volume.max=5` to `server`) would not suppress the entrypoint's default, and the duplicate flag was silently appended to the command line — relying on last-wins parsing for correctness. Match double-dash explicitly so the override is detected for every case in the file. --- docker/Dockerfile.go_build | 5 +++++ docker/Dockerfile.local | 5 +++++ docker/Dockerfile.rocksdb_large | 5 +++++ docker/entrypoint.sh | 17 +++++++++++++++-- 4 files changed, 30 insertions(+), 2 deletions(-) diff --git a/docker/Dockerfile.go_build b/docker/Dockerfile.go_build index a80a3cdef..051831dd7 100644 --- a/docker/Dockerfile.go_build +++ b/docker/Dockerfile.go_build @@ -89,3 +89,8 @@ WORKDIR /data # Entrypoint will handle permission fixes and user switching ENTRYPOINT ["/entrypoint.sh"] +# Default to a complete single-process cluster (master+volume+filer+S3+admin) +# so the image is usable out of the box — including in environments like +# GitHub Actions service containers that cannot pass arguments to the entrypoint. +# Override with any other subcommand at `docker run` / compose time. +CMD ["mini", "-dir=/data"] diff --git a/docker/Dockerfile.local b/docker/Dockerfile.local index c37e5f78a..a275cc639 100644 --- a/docker/Dockerfile.local +++ b/docker/Dockerfile.local @@ -40,3 +40,8 @@ WORKDIR /data # Entrypoint will handle permission fixes and user switching ENTRYPOINT ["/entrypoint.sh"] +# Default to a complete single-process cluster (master+volume+filer+S3+admin) +# so the image is usable out of the box — including in environments like +# GitHub Actions service containers that cannot pass arguments to the entrypoint. +# Override with any other subcommand at `docker run` / compose time. +CMD ["mini", "-dir=/data"] diff --git a/docker/Dockerfile.rocksdb_large b/docker/Dockerfile.rocksdb_large index 6013aacf9..0274d2940 100644 --- a/docker/Dockerfile.rocksdb_large +++ b/docker/Dockerfile.rocksdb_large @@ -68,3 +68,8 @@ WORKDIR /data # Entrypoint will handle permission fixes and user switching ENTRYPOINT ["/entrypoint.sh"] +# Default to a complete single-process cluster (master+volume+filer+S3+admin) +# so the image is usable out of the box — including in environments like +# GitHub Actions service containers that cannot pass arguments to the entrypoint. +# Override with any other subcommand at `docker run` / compose time. +CMD ["mini", "-dir=/data"] diff --git a/docker/entrypoint.sh b/docker/entrypoint.sh index 6632f6645..7ce0595ec 100755 --- a/docker/entrypoint.sh +++ b/docker/entrypoint.sh @@ -37,17 +37,21 @@ if [ "$(id -u)" = "0" ]; then fi isArgPassed() { + # Match both `-flag` and `--flag` (and their `=value` forms): the Go fla9 + # library accepts both, and users may pick either form on the CLI. arg="$1" argWithEqualSign="$1=" + argDouble="-$1" + argDoubleWithEqualSign="-$1=" shift while [ $# -gt 0 ]; do passedArg="$1" shift case $passedArg in - "$arg") + "$arg"|"$argDouble") return 0 ;; - "$argWithEqualSign"*) + "$argWithEqualSign"*|"$argDoubleWithEqualSign"*) return 0 ;; esac @@ -95,6 +99,15 @@ case "$1" in exec /usr/bin/weed -logtostderr=true server $ARGS $@ ;; + 'mini') + ARGS="-dir=/data" + if isArgPassed "-dir" "$@"; then + ARGS="" + fi + shift + exec /usr/bin/weed -logtostderr=true mini $ARGS $@ + ;; + 'filer') ARGS="" shift