Skip to content

Commit ffb9669

Browse files
committed
Add support for mounting application under a context root
Signed-off-by: Kristian Berg <[email protected]>
1 parent cd377e3 commit ffb9669

File tree

3 files changed

+10
-3
lines changed

3 files changed

+10
-3
lines changed

Dockerfile

+2-1
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ LABEL maintainer="Kristian Berg <[email protected]>" \
2222

2323
ENV UVICORN_PORT 8000
2424
ENV UVICORN_HOST 0.0.0.0
25+
ENV CONTEXT_ROOT ""
2526
USER root
2627
RUN apt-get update && \
2728
apt-get install -y gcc && \
@@ -37,6 +38,6 @@ USER 1001:100
3738
WORKDIR /app
3839
EXPOSE $UVICORN_PORT
3940
HEALTHCHECK --interval=30s --timeout=5s --retries=3 \
40-
CMD curl -I --silent --fail "http://localhost:$UVICORN_PORT/" || exit 1
41+
CMD curl -I --silent --fail "http://localhost:$UVICORN_PORT/$CONTEXT_ROOT" || exit 1
4142
ENTRYPOINT ["/bin/start_uvicorn"]
4243
CMD ["asgi:app"]

README.md

+2-1
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,9 @@ environment flags to control how the ASGI application is started.
1414

1515
Flag | Default | Comment
1616
---------------- | ----------------- | ---------------------------------------------------
17-
UVICORN_PORT | 8000 | Application port.
17+
UVICORN_PORT | 8000 | Application port.
1818
UVICORN_HOST | 0.0.0.0 | Application bind address.
19+
CONTEXT_ROOT | None | Context root where application is served.
1920

2021
### Creating a Dockerfile
2122

start_uvicorn

+6-1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,7 @@
11
#!/bin/bash
2-
uvicorn --port $UVICORN_PORT --host $UVICORN_HOST --log-level ${LOG_LEVEL:-info} $*
2+
if [ $CONTEXT_ROOT ]; then
3+
ROOT="--root-path $CONTEXT_ROOT"
4+
else
5+
ROOT=""
6+
fi
7+
uvicorn --port $UVICORN_PORT --host $UVICORN_HOST --log-level ${LOG_LEVEL:-info} $ROOT_PATH $*

0 commit comments

Comments
 (0)