Skip to content

Commit

Permalink
feat(web): env vars to rewrite favicon and title on Docker (#1235)
Browse files Browse the repository at this point in the history
  • Loading branch information
KeisukeYamashita authored Nov 11, 2024
1 parent cb0fe8d commit 26db1cd
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
2 changes: 2 additions & 0 deletions web/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -53,12 +53,14 @@ 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_PASSWORD_POLICY=null
ENV REEARTH_WEB_PLUGINS=null
ENV REEARTH_WEB_POLICY=null
ENV REEARTH_WEB_PUBLISHED=null
ENV REEARTH_WEB_TITLE=

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
15 changes: 14 additions & 1 deletion web/docker/40-envsubst-on-reearth-config.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,21 @@

set -e

# rewrite index.html to change title and favicon
# rewrite index.html and published.html to change title and favicon
_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"
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"
fi

# generate reearth_config.json
_REEARTH_CONFIG_TEMPLATE_FILE="/opt/reearth/reearth_config.json.template"
Expand Down

0 comments on commit 26db1cd

Please sign in to comment.