-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: KeisukeYamashita <[email protected]>
- Loading branch information
1 parent
982b052
commit 035fb6a
Showing
9 changed files
with
361 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
* | ||
|
||
!docker/ | ||
!src/ | ||
|
||
!.yarnrc.yml | ||
!index.html | ||
!i18next-parser.config.js | ||
!tsconfig.json | ||
!package.json | ||
!published.html | ||
!vite.config.ts | ||
!yarn.lock |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
FROM node:20.18.0-slim AS builder | ||
WORKDIR /app | ||
|
||
ARG NODE_OPTIONS="--max-old-space-size=4096" | ||
ARG GITHUB_SHA | ||
ENV NODE_OPTIONS=$NODE_OPTIONS | ||
ENV GITHUB_SHA=$GITHUB_SHA | ||
|
||
RUN --mount=type=bind,source=package.json,target=package.json \ | ||
--mount=type=cache,target=/root/.npm,sharing=locked \ | ||
corepack enable | ||
|
||
RUN --mount=type=bind,source=.yarnrc.yml,target=.yarnrc.yml \ | ||
--mount=type=bind,source=package.json,target=package.json \ | ||
--mount=type=bind,source=yarn.lock,target=yarn.lock \ | ||
--mount=type=cache,target=/root/.yarn,sharing=locked \ | ||
yarn install --frozen-lockfile | ||
|
||
RUN --mount=type=bind,source=.yarnrc.yml,target=.yarnrc.yml \ | ||
--mount=type=bind,source=package.json,target=package.json \ | ||
--mount=type=bind,source=yarn.lock,target=yarn.lock \ | ||
--mount=type=bind,source=index.html,target=index.html \ | ||
--mount=type=bind,source=published.html,target=published.html \ | ||
--mount=type=bind,source=tsconfig.json,target=tsconfig.json \ | ||
--mount=type=bind,source=vite.config.ts,target=vite.config.ts \ | ||
--mount=type=bind,source=src,target=src \ | ||
--mount=type=cache,target=/root/.yarn,sharing=locked \ | ||
yarn build | ||
|
||
FROM nginx:1.27-alpine | ||
WORKDIR /usr/share/nginx/html | ||
|
||
# Quite the Nginx startup logs. | ||
ENV NGINX_ENTRYPOINT_QUIET_LOGS=true | ||
|
||
# Default to Cloud Run port. | ||
# Ref: https://cloud.google.com/run/docs/reference/container-contract#port | ||
ENV PORT=8080 | ||
|
||
# Defaults Google Cloud Load Balancer header. | ||
# Ref: https://cloud.google.com/load-balancing/docs/https#target-proxies | ||
ENV REAL_IP_HEADER=X-Forwarded-For | ||
|
||
# Default values. | ||
ENV REEARTH_API=null | ||
ENV REEARTH_AUTH0_AUDIENCE=null | ||
ENV REEARTH_AUTH0_CLIENT_ID=null | ||
ENV REEARTH_AUTH0_DOMAIN=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 | ||
COPY --chown=nginx:nginx docker/40-envsubst-on-reearth-config.sh /docker-entrypoint.d | ||
COPY --chown=nginx:nginx docker/reearth_config.json.template /opt/reearth/reearth_config.json.template | ||
|
||
ENTRYPOINT ["/docker-entrypoint.sh"] | ||
CMD ["nginx", "-g", "daemon off;"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
#!/bin/sh | ||
|
||
set -e | ||
|
||
# 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_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_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 | ||
_REEARTH_CONFIG_TEMPLATE_FILE="/opt/reearth/reearth_config.json.template" | ||
_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 | ||
value=$(printenv "$var") | ||
if [ -z "$value" ]; then | ||
eval "export $var='\"\"'" | ||
elif [ "$value" != "null" ] && [ "$value" != "true" ] && [ "$value" != "false" ] && ! echo "$value" | grep -qE '^\{.*\}$|^\[.*\]$'; then | ||
eval "export $var='\"${value}\"'" | ||
fi | ||
done | ||
} | ||
|
||
wrap_reearth_variables "$@" | ||
envsubst < "$_REEARTH_CONFIG_TEMPLATE_FILE" > "$_REEARTH_CONFIG_OUTPUT_FILE" |
Oops, something went wrong.