Skip to content
This repository has been archived by the owner on Jun 17, 2024. It is now read-only.

Commit

Permalink
chore: add 'standalone' mode
Browse files Browse the repository at this point in the history
  • Loading branch information
miwurster committed Apr 10, 2024
1 parent 9630763 commit 0673897
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 8 deletions.
File renamed without changes.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ docker build -t planqk-cli-serve .
Once the container image has been built, start it with the following command:

```bash
docker run -p 8000:8000 -v "$(pwd):/user_code" planqk-cli-serve
docker run -it -e PORT=8000 -p 8000:8000 -v "$(pwd):/user_code" planqk-cli-serve standalone
```

## Development
Expand Down
42 changes: 35 additions & 7 deletions entrypoint.sh
Original file line number Diff line number Diff line change
@@ -1,11 +1,39 @@
#!/bin/bash

set -e
trap 'echo "Error: Command failed with exit code $?" >&2; exit 1' ERR
set -eu
set -o pipefail

if [ -f dependencies.txt ] && cmp -s dependencies.txt /user_code/requirements.txt; then
exec "$@"
else
cp /user_code/requirements.txt dependencies.txt
function main {
local path

while [[ "${#}" != 0 ]]; do
case "${1}" in
standalone)
echo "Running in standalone mode"
build
start uvicorn src.app:app --reload --host 0.0.0.0 --port $PORT
exit 0
;;

*)
start "${@:-}"
exit 0
;;
esac
done
}

function build() {
pip install -r /user_code/requirements.txt
fi
cp /user_code/requirements.txt dependencies.txt
}

function start() {
if [ -f dependencies.txt ] && cmp -s dependencies.txt /user_code/requirements.txt; then
exec "$@"
else
build
fi
}

main "${@:-}"

0 comments on commit 0673897

Please sign in to comment.