Skip to content

Commit

Permalink
feat(web): validate reearth_config.json on startup
Browse files Browse the repository at this point in the history
Signed-off-by: KeisukeYamashita <[email protected]>
  • Loading branch information
KeisukeYamashita authored and rot1024 committed Jan 31, 2025
1 parent 751818d commit b582480
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
3 changes: 3 additions & 0 deletions web/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,9 @@ ENV REEARTH_PUBLISHED=null
ENV REEARTH_TITLE=
ENV REEARTH_UNSAFE_PLUGIN_URLS=[]

RUN --mount=type=cache,target=/var/cache/apk \
apk add --no-cache jq

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
COPY --chown=nginx:nginx docker/40-envsubst-on-reearth-config.sh /docker-entrypoint.d
Expand Down
4 changes: 4 additions & 0 deletions web/docker/40-envsubst-on-reearth-config.sh
Original file line number Diff line number Diff line change
Expand Up @@ -36,3 +36,7 @@ wrap_reearth_variables() {

wrap_reearth_variables "$@"
envsubst < "$_REEARTH_CONFIG_TEMPLATE_FILE" > "$_REEARTH_CONFIG_OUTPUT_FILE"
if ! jq empty "$_REEARTH_CONFIG_OUTPUT_FILE" > /dev/null 2>&1; then
echo "Invalid JSON configuration file $_REEARTH_CONFIG_OUTPUT_FILE" >&2
exit 1
fi

0 comments on commit b582480

Please sign in to comment.