Skip to content

Commit

Permalink
chore(docker): fully support TRAME_URL_PREFIX
Browse files Browse the repository at this point in the history
  • Loading branch information
jourdain committed Aug 5, 2024
1 parent ef9b5cc commit ac7f71f
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 4 deletions.
5 changes: 5 additions & 0 deletions docker/scripts/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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}"
Expand Down
7 changes: 4 additions & 3 deletions docker/scripts/runtime_patch.sh
Original file line number Diff line number Diff line change
@@ -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)
Expand All @@ -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

Expand All @@ -36,5 +37,5 @@ then
OUTPUT="${OUTPUT//$REPLACEMENT_STRING/$TRAME_URL_PREFIX}"
echo -e "$OUTPUT" > "${CONFIG_OUTPUT}"

systemctl restart apache2
service apache2 restart
fi
2 changes: 1 addition & 1 deletion examples/deploy/docker/SingleFile/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM kitware/trame
FROM kitware/trame:py3.10

COPY --chown=trame-user:trame-user . /deploy

Expand Down
7 changes: 7 additions & 0 deletions examples/deploy/docker/SingleFile/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit ac7f71f

Please sign in to comment.