From ac7f71fc23511f19d01c93d7ffeeb86f4cf02af4 Mon Sep 17 00:00:00 2001 From: Sebastien Jourdain Date: Mon, 5 Aug 2024 11:10:55 -0600 Subject: [PATCH] chore(docker): fully support TRAME_URL_PREFIX --- docker/scripts/run.sh | 5 +++++ docker/scripts/runtime_patch.sh | 7 ++++--- examples/deploy/docker/SingleFile/Dockerfile | 2 +- examples/deploy/docker/SingleFile/README.md | 7 +++++++ 4 files changed, 17 insertions(+), 4 deletions(-) diff --git a/docker/scripts/run.sh b/docker/scripts/run.sh index 406a1d03..6c36ecb5 100755 --- a/docker/scripts/run.sh +++ b/docker/scripts/run.sh @@ -27,6 +27,11 @@ if [[ -n $TRAME_USE_HOST ]]; then REPLACEMENT_STRING="ws://$REPLACEMENT_STRING" fi OUTPUT="${OUTPUT//$REPLACEMENT_STRING/$TRAME_USE_HOST}" +elif [[ -n "$TRAME_URL_PREFIX" ]]; then + # Need to patch session URL with prefix + REPLACEMENT_STRING="ws://USE_HOST/proxy" + OUTPUT_STRING="ws://USE_HOST$TRAME_URL_PREFIX/proxy" + OUTPUT="${OUTPUT//$REPLACEMENT_STRING/$OUTPUT_STRING}" fi echo -e "$OUTPUT" > "${LAUNCHER_PATH}" diff --git a/docker/scripts/runtime_patch.sh b/docker/scripts/runtime_patch.sh index d64ec942..bc9bea78 100755 --- a/docker/scripts/runtime_patch.sh +++ b/docker/scripts/runtime_patch.sh @@ -1,7 +1,7 @@ #!/usr/bin/env bash # Remap trame-user to a file/directory owner (TRAME_USER_DATA) -if [ -d "$TRAME_USER_DATA" ] +if [[ -n "$TRAME_USER_DATA" ]] then new_uid=$(stat -c '%u' $TRAME_USER_DATA) new_gid=$(stat -c '%g' $TRAME_USER_DATA) @@ -25,8 +25,9 @@ then fi # Patch Apache configuration to add prefix -if [ -d "$TRAME_URL_PREFIX" ] +if [[ -n "$TRAME_URL_PREFIX" ]] then + # Fix Apache TEMPLATE_INPUT=/opt/trame/apache.tpl CONFIG_OUTPUT=/etc/apache2/sites-available/001-trame.conf @@ -36,5 +37,5 @@ then OUTPUT="${OUTPUT//$REPLACEMENT_STRING/$TRAME_URL_PREFIX}" echo -e "$OUTPUT" > "${CONFIG_OUTPUT}" - systemctl restart apache2 + service apache2 restart fi \ No newline at end of file diff --git a/examples/deploy/docker/SingleFile/Dockerfile b/examples/deploy/docker/SingleFile/Dockerfile index 56c6e56b..f6e1d586 100644 --- a/examples/deploy/docker/SingleFile/Dockerfile +++ b/examples/deploy/docker/SingleFile/Dockerfile @@ -1,4 +1,4 @@ -FROM kitware/trame +FROM kitware/trame:py3.10 COPY --chown=trame-user:trame-user . /deploy diff --git a/examples/deploy/docker/SingleFile/README.md b/examples/deploy/docker/SingleFile/README.md index 63001bb0..f7e2c9ef 100644 --- a/examples/deploy/docker/SingleFile/README.md +++ b/examples/deploy/docker/SingleFile/README.md @@ -10,6 +10,13 @@ docker build -t trame-app . docker run -it --rm -p 8080:80 trame-app ``` +Or if you need some prefix + +```bash +docker run -it --rm -p 8080:80 -e TRAME_URL_PREFIX=/my-app/sub/path trame-app +``` + + # Deploying into CapRover If that directory was at the root of a git repo you could run the following command line