Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ci(web): add dockerfiles #89

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions web/.dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
node_modules
dist
15 changes: 15 additions & 0 deletions web/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
FROM node:18.16.1-slim AS node
WORKDIR /work
# RUN apt-get update && apt-get install -y python3 make gcc g++ \
# && apt-get clean \
# && rm -rf /var/lib/apt/lists/*
COPY package.json yarn.lock ./
RUN yarn install
COPY . .
RUN yarn build && yarn build:ext

FROM nginx:1.27-alpine
COPY --from=node /work/dist/ /opt/reearth-marketplace
COPY docker/reearth_config.json.tmpl /tmp/reearth_config.json.tmpl
COPY docker/nginx.conf /etc/nginx/conf.d/default.conf
COPY docker/40-envsubst-on-reearth_config.sh /docker-entrypoint.d/
8 changes: 8 additions & 0 deletions web/docker/40-envsubst-on-reearth_config.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#!/bin/sh

set -e

TEMPLATE_FILE="/tmp/reearth_config.json.tmpl"
OUTPUT_FILE="/opt/reearth-marketplace/reearth_config.json"

envsubst < "$TEMPLATE_FILE" > "$OUTPUT_FILE"
35 changes: 35 additions & 0 deletions web/docker/nginx.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@

#docs: https://cloud.google.com/load-balancing/docs/https?hl=ja#x-forwarded-for_header
set_real_ip_from 130.211.0.0/22;
set_real_ip_from 35.191.0.0/16;
real_ip_header X-Forwarded-For;

log_format cloud_logging_json escape=json '{'
'"time": "$time_iso8601",'
'"remote_ip": "$remote_addr",'
'"remote_user": "$remote_user",'
'"request": "$request",'
'"status": "$status",'
'"body_bytes_sent": "$body_bytes_sent",'
'"http_referer": "$http_referer",'
'"http_user_agent": "$http_user_agent",'
'"request_time": "$request_time",'
'"upstream_response_time": "$upstream_response_time",'
'"upstream_addr": "$upstream_addr",'
'"request_id": "$request_id",'
'"server_name": "$server_name"'
'}';

server {
listen 8080;
server_name _;


access_log /dev/stdout cloud_logging_json;
error_log /dev/stderr;

location / {
root /opt/reearth-marketplace;
try_files $uri /index.html;
}
}
10 changes: 10 additions & 0 deletions web/docker/reearth_config.json.tmpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"marketplaceApi": "${MARKETPLACE_API}",
"authClientId": "${AUTH_CLIENT_ID}",
"authDomain": "${AUTH_DOMAIN}",
"authAudience": "${AUTH_AUDIENCE}",
"reportUrl": "${REPORT_URL}",
"reearthApi": "${REEARTH_API}",
"reearthWeb": "${REEARTH_WEB}"
}

Loading