Skip to content

Commit

Permalink
fix(web): removeVISUALIZER for runtime environment variables (#1280)
Browse files Browse the repository at this point in the history
Signed-off-by: KeisukeYamashita <19yamashita15@gmail.com>
  • Loading branch information
KeisukeYamashita authored Dec 12, 2024
1 parent db9eef6 commit 2f10541
Show file tree
Hide file tree
Showing 3 changed files with 51 additions and 51 deletions.
44 changes: 22 additions & 22 deletions web/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -42,28 +42,28 @@ ENV PORT=8080
ENV REAL_IP_HEADER=X-Forwarded-For

# Default values.
ENV REEARTH_WEB_API=null
ENV REEARTH_WEB_AUTH0_AUDIENCE=null
ENV REEARTH_WEB_AUTH0_CLIENT_ID=null
ENV REEARTH_WEB_AUTH0_DOMAIN=null
ENV REEARTH_WEB_BRAND=null
ENV REEARTH_WEB_CESIUM_ION_ACCESS_TOKEN=null
ENV REEARTH_WEB_CLOUD_API=null
ENV REEARTH_WEB_CURRENT_TOS=null
ENV REEARTH_WEB_DEVELOPER_MODE=null
ENV REEARTH_WEB_DOCUMENTATION_URL=null
ENV REEARTH_WEB_EARLY_ACCESS_ADMINS=[]
ENV REEARTH_WEB_EXTENSION_URLS=[]
ENV REEARTH_WEB_FAVICON_URL=
ENV REEARTH_WEB_IP=null
ENV REEARTH_WEB_MARKETPLACE_URL=null
ENV REEARTH_WEB_MULTI_TENANT=null
ENV REEARTH_WEB_PASSWORD_POLICY=null
ENV REEARTH_WEB_PLUGINS=null
ENV REEARTH_WEB_POLICY=null
ENV REEARTH_WEB_PUBLISHED=null
ENV REEARTH_WEB_TITLE=
ENV REEARTH_WEB_UNSAFE_PLUGIN_URLS=[]
ENV REEARTH_API=null
ENV REEARTH_AUTH0_AUDIENCE=null
ENV REEARTH_AUTH0_CLIENT_ID=null
ENV REEARTH_AUTH0_DOMAIN=null
ENV REEARTH_BRAND=null
ENV REEARTH_CESIUM_ION_ACCESS_TOKEN=null
ENV REEARTH_CLOUD_API=null
ENV REEARTH_CURRENT_TOS=null
ENV REEARTH_DEVELOPER_MODE=null
ENV REEARTH_DOCUMENTATION_URL=null
ENV REEARTH_EARLY_ACCESS_ADMINS=[]
ENV REEARTH_EXTENSION_URLS=[]
ENV REEARTH_FAVICON_URL=
ENV REEARTH_IP=null
ENV REEARTH_MARKETPLACE_URL=null
ENV REEARTH_MULTI_TENANT=null
ENV REEARTH_PASSWORD_POLICY=null
ENV REEARTH_PLUGINS=null
ENV REEARTH_POLICY=null
ENV REEARTH_PUBLISHED=null
ENV REEARTH_TITLE=
ENV REEARTH_UNSAFE_PLUGIN_URLS=[]

COPY --from=builder --chown=nginx:nginx /app/dist /usr/share/nginx/html
COPY --chown=nginx:nginx docker/nginx.conf.template /etc/nginx/templates/nginx.conf.template
Expand Down
18 changes: 9 additions & 9 deletions web/docker/40-envsubst-on-reearth-config.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,16 @@ set -e
_REEARTH_HTML_FILE="/usr/share/nginx/html/index.html"
_REEARTH_PUBLISHED_HTML_FILE="/usr/share/nginx/html/published.html"

# Rewrite title tag in index.html only if REEARTH_WEB_TITLE is set
if [ -n "$REEARTH_WEB_TITLE" ]; then
sed -i -e "s|<title>.*</title>|<title>${REEARTH_WEB_TITLE}</title>|g" "$_REEARTH_HTML_FILE"
sed -i -e "s|<title>.*</title>|<title>${REEARTH_WEB_TITLE}</title>|g" "$_REEARTH_PUBLISHED_HTML_FILE"
# Rewrite title tag in index.html only if REEARTH_TITLE is set
if [ -n "$REEARTH_TITLE" ]; then
sed -i -e "s|<title>.*</title>|<title>${REEARTH_TITLE}</title>|g" "$_REEARTH_HTML_FILE"
sed -i -e "s|<title>.*</title>|<title>${REEARTH_TITLE}</title>|g" "$_REEARTH_PUBLISHED_HTML_FILE"
fi

# Rewrite favicon in index.html and published.html only if REEARTH_WEB_FAVICON_URL is set
if [ -n "$REEARTH_WEB_FAVICON_URL" ]; then
sed -i -e "s|<link rel=\"icon\" href=\"[^\"]*\" />|<link rel=\"icon\" href=\"${REEARTH_WEB_FAVICON_URL}\" />|g" "$_REEARTH_HTML_FILE"
sed -i -e "s|<link rel=\"icon\" href=\"[^\"]*\" />|<link rel=\"icon\" href=\"${REEARTH_WEB_FAVICON_URL}\" />|g" "$_REEARTH_PUBLISHED_HTML_FILE"
# Rewrite favicon in index.html and published.html only if REEARTH_FAVICON_URL is set
if [ -n "$REEARTH_FAVICON_URL" ]; then
sed -i -e "s|<link rel=\"icon\" href=\"[^\"]*\" />|<link rel=\"icon\" href=\"${REEARTH_FAVICON_URL}\" />|g" "$_REEARTH_HTML_FILE"
sed -i -e "s|<link rel=\"icon\" href=\"[^\"]*\" />|<link rel=\"icon\" href=\"${REEARTH_FAVICON_URL}\" />|g" "$_REEARTH_PUBLISHED_HTML_FILE"
fi

# generate reearth_config.json
Expand All @@ -24,7 +24,7 @@ _REEARTH_CONFIG_OUTPUT_FILE="/usr/share/nginx/html/reearth_config.json"

# Wrap with "" if the value doesn't start with '{[' and end with ']}' (JSON) or "null".
wrap_reearth_variables() {
for var in $(env | grep '^REEARTH_WEB' | cut -d= -f1); do
for var in $(env | grep '^REEARTH_' | cut -d= -f1); do
value=$(printenv "$var")
if [ -z "$value" ]; then
eval "export $var='\"\"'"
Expand Down
40 changes: 20 additions & 20 deletions web/docker/reearth_config.json.template
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
{
"api": ${REEARTH_WEB_API},
"auth0Audience": ${REEARTH_WEB_AUTH0_AUDIENCE},
"auth0ClientId": ${REEARTH_WEB_AUTH0_CLIENT_ID},
"auth0Domain": ${REEARTH_WEB_AUTH0_DOMAIN},
"brand": ${REEARTH_WEB_BRAND},
"cesiumIonAccessToken": ${REEARTH_WEB_CESIUM_ION_ACCESS_TOKEN},
"cloudApi": ${REEARTH_WEB_CLOUD_API},
"currentTos": ${REEARTH_WEB_CURRENT_TOS},
"developerMode": ${REEARTH_WEB_DEVELOPER_MODE},
"documentationUrl": ${REEARTH_WEB_DOCUMENTATION_URL},
"earlyAccessAdmins": ${REEARTH_WEB_EARLY_ACCESS_ADMINS},
"extensionUrls": ${REEARTH_WEB_EXTENSION_URLS},
"ip": ${REEARTH_WEB_IP},
"marketplaceUrl": ${REEARTH_WEB_MARKETPLACE_URL},
"multiTenant": ${REEARTH_WEB_MULTI_TENANT},
"passwordPolicy": ${REEARTH_WEB_PASSWORD_POLICY},
"plugins": ${REEARTH_WEB_PLUGINS},
"policy": ${REEARTH_WEB_POLICY},
"published": ${REEARTH_WEB_PUBLISHED},
"unsafePluginUrls": ${REEARTH_WEB_UNSAFE_PLUGIN_URLS}
"api": ${REEARTH_API},
"auth0Audience": ${REEARTH_AUTH0_AUDIENCE},
"auth0ClientId": ${REEARTH_AUTH0_CLIENT_ID},
"auth0Domain": ${REEARTH_AUTH0_DOMAIN},
"brand": ${REEARTH_BRAND},
"cesiumIonAccessToken": ${REEARTH_CESIUM_ION_ACCESS_TOKEN},
"cloudApi": ${REEARTH_CLOUD_API},
"currentTos": ${REEARTH_CURRENT_TOS},
"developerMode": ${REEARTH_DEVELOPER_MODE},
"documentationUrl": ${REEARTH_DOCUMENTATION_URL},
"earlyAccessAdmins": ${REEARTH_EARLY_ACCESS_ADMINS},
"extensionUrls": ${REEARTH_EXTENSION_URLS},
"ip": ${REEARTH_IP},
"marketplaceUrl": ${REEARTH_MARKETPLACE_URL},
"multiTenant": ${REEARTH_MULTI_TENANT},
"passwordPolicy": ${REEARTH_PASSWORD_POLICY},
"plugins": ${REEARTH_PLUGINS},
"policy": ${REEARTH_POLICY},
"published": ${REEARTH_PUBLISHED},
"unsafePluginUrls": ${REEARTH_UNSAFE_PLUGIN_URLS}
}

0 comments on commit 2f10541

Please sign in to comment.