Skip to content

Commit

Permalink
rename environment variables of Docker container
Browse files Browse the repository at this point in the history
  • Loading branch information
TaiSakuma committed Feb 4, 2022
1 parent d29ae68 commit bc7db8b
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 18 deletions.
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,17 +28,17 @@ Docker images of the Nextline front-end web app are created as

You can configure the web app in the container with these variables.

| Environment variable | Default value | Description |
| ---------------------- | ----------------------- | ------------------------------ |
| `VUE_APP_PUBLIC_PATH` | `/` | Path in the URL of the web app |
| `VUE_APP_GRAPHQL_HTTP` | `http://localhost:8000` | URL of the GraphQL API server |
| Environment variable | Default value | Description |
| -------------------- | ----------------------- | ------------------------------ |
| `PUBLIC_PATH` | `/` | Path in the URL of the web app |
| `GRAPHQL_HTTP` | `http://localhost:8000` | URL of the GraphQL API server |

For example, if you are to run the web app at the port `8080` with the path
`/nextline/` and use the GraphQL API server at `http://localhost:5000/graphql`,
you can do so with the following command.

```bash
docker run -p 8080:80 -e VUE_APP_PUBLIC_PATH=/nextline/ -e VUE_APP_GRAPHQL_HTTP=http://localhost:5000/graphql ghcr.io/simonsobs/nextline-web
docker run -p 8080:80 -e PUBLIC_PATH=/nextline/ -e GRAPHQL_HTTP=http://localhost:5000/graphql ghcr.io/simonsobs/nextline-web
```

If you are on the localhost, the web app is running at <http://localhost:8080/nextline/>.
Expand Down
26 changes: 13 additions & 13 deletions docker/cmd.sh
Original file line number Diff line number Diff line change
@@ -1,26 +1,26 @@
#!/bin/bash

##__________________________________________________________________||
VUE_APP_GRAPHQL_HTTP_DEFAULT="http://localhost:8000"
VUE_APP_PUBLIC_PATH_DEFAULT="/"
GRAPHQL_HTTP_DEFAULT="http://localhost:8000"
PUBLIC_PATH_DEFAULT="/"

VUE_APP_GRAPHQL_HTTP_PLACEHOLDER="graphql_http_placeholder"
VUE_APP_PUBLIC_PATH_PLACEHOLDER="/public_path_placeholder/"
GRAPHQL_HTTP_PLACEHOLDER="graphql_http_placeholder"
PUBLIC_PATH_PLACEHOLDER="/public_path_placeholder/"

HTML_DIR="/app/site"

##__________________________________________________________________||
if [ -z $VUE_APP_GRAPHQL_HTTP ]
if [ -z $GRAPHQL_HTTP ]
then
echo 'Warning: $VUE_APP_GRAPHQL_HTTP is not set!'
command="VUE_APP_GRAPHQL_HTTP=$VUE_APP_GRAPHQL_HTTP_DEFAULT"
echo 'Warning: $GRAPHQL_HTTP is not set!'
command="GRAPHQL_HTTP=$GRAPHQL_HTTP_DEFAULT"
echo + $command
eval $command
fi

if [ -z $VUE_APP_PUBLIC_PATH ]
if [ -z $PUBLIC_PATH ]
then
command="VUE_APP_PUBLIC_PATH=$VUE_APP_PUBLIC_PATH_DEFAULT"
command="PUBLIC_PATH=$PUBLIC_PATH_DEFAULT"
echo + $command
eval $command
fi
Expand All @@ -31,14 +31,14 @@ then
exit 1
fi

if [ "$VUE_APP_PUBLIC_PATH" != "$VUE_APP_PUBLIC_PATH_DEFAULT" ]
if [ "$PUBLIC_PATH" != "$PUBLIC_PATH_DEFAULT" ]
then
HTML_DIR_TEMP="$(mktemp -d)/site"
command="mv $HTML_DIR $HTML_DIR_TEMP"
echo + $command
eval $command

HTML_DIR=$(echo $HTML_DIR/$VUE_APP_PUBLIC_PATH | tr -s /)
HTML_DIR=$(echo $HTML_DIR/$PUBLIC_PATH | tr -s /)
HTML_DIR=${HTML_DIR%/} # e.g., /app/site/vue
command="mkdir -p $(dirname $HTML_DIR)"
echo + $command
Expand All @@ -55,13 +55,13 @@ fi
$command
for f in $(find . -type f);
do
command="sed -i \"s#$VUE_APP_GRAPHQL_HTTP_PLACEHOLDER#$VUE_APP_GRAPHQL_HTTP#g\" $f";
command="sed -i \"s#$GRAPHQL_HTTP_PLACEHOLDER#$GRAPHQL_HTTP#g\" $f";
echo + $command;
eval $command;
done
for f in $(find . -type f);
do
command="sed -i \"s#$VUE_APP_PUBLIC_PATH_PLACEHOLDER#$VUE_APP_PUBLIC_PATH#g\" $f";
command="sed -i \"s#$PUBLIC_PATH_PLACEHOLDER#$PUBLIC_PATH#g\" $f";
echo + $command;
eval $command;
done
Expand Down

0 comments on commit bc7db8b

Please sign in to comment.