diff --git a/Dockerfile b/Dockerfile index 461f84b..f8460e2 100644 --- a/Dockerfile +++ b/Dockerfile @@ -22,6 +22,8 @@ RUN pip install --upgrade pip COPY dist/*.tar.gz ${WORK_DIR}/dist/nvme_spex.tar.gz +COPY scripts/cmd.sh . RUN pip install hypercorn dist/nvme_spex.tar.gz[spexsrv] -CMD hypercorn --reload --bind 0.0.0.0:8000 spexsrv.application.app:app +ENTRYPOINT [ "./cmd.sh" ] +CMD ["webserver"] diff --git a/scripts/cmd.sh b/scripts/cmd.sh new file mode 100755 index 0000000..6ee7a99 --- /dev/null +++ b/scripts/cmd.sh @@ -0,0 +1,40 @@ +#!/usr/bin/env bash + +# SPDX-FileCopyrightText: 2023 Samsung Electronics Co., Ltd +# +# SPDX-License-Identifier: BSD-3-Clause + + +app_name=$(basename $0) + +sub_help(){ + echo "Usage: $app_name [options]\n" + echo "Subcommands:" + echo " webserver Start webserver for linting NVMe specifications" + echo " run Run NVMe-Spex" + echo "" +} + + +subcommand="${1}" +case $subcommand in + "" | "-h" | "--help") + sub_help + ;; + "run") + shift + echo "Running nvme-spex ${@}" + spex $@ + exit 0 + ;; + "webserver") + echo "Webserver starting" + hypercorn --reload --bind 0.0.0.0:8000 spexsrv.application.app:app + exit 0 + ;; + *) + echo "Error: '$subcommand' is not a known subcommand." >&2 + echo " Run '$app_name --help' for a list of known subcommands." >&2 + exit 1 + ;; +esac \ No newline at end of file