-
Notifications
You must be signed in to change notification settings - Fork 46
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 <19yamashita15@gmail.com>
- Loading branch information
1 parent
cf658e7
commit adf6fd3
Showing
10 changed files
with
359 additions
and
12 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,69 @@ | ||
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_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_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_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 | ||
|
||
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,25 @@ | ||
#!/bin/sh | ||
|
||
set -e | ||
|
||
# rewrite index.html to change title and favicon | ||
_REEARTH_HTML_FILE="/usr/share/nginx/html/index.html" | ||
|
||
# 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.