feat(docker): default CMD to mini -dir=/data for service-container use (#9255)

* 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.
This commit is contained in:
Chris Lu
2026-04-27 21:21:58 -07:00
committed by GitHub
parent d92c5e057a
commit e4a635a04d
4 changed files with 30 additions and 2 deletions

View File

@@ -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"]

View File

@@ -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"]

View File

@@ -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"]

View File

@@ -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