Skip to content

Commit

Permalink
feat(docker): docker entrypoint with run/webserver capabilities
Browse files Browse the repository at this point in the history
Add new `cmd.sh` script with case matches for subcommands.
This enables the docker contrainer to both serv a webserver and
run nvme-spex directly on files.

Signed-off-by: Morten B. Rasmussen <m.rasmussen@samsung.com>
  • Loading branch information
mbrsamsung committed Sep 26, 2024
1 parent 7f18df2 commit 3b3c3af
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 1 deletion.
4 changes: 3 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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"]
40 changes: 40 additions & 0 deletions scripts/cmd.sh
Original file line number Diff line number Diff line change
@@ -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 <subcommand> [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

0 comments on commit 3b3c3af

Please sign in to comment.