-
-
Notifications
You must be signed in to change notification settings - Fork 663
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
184 additions
and
33 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
FROM openresty/openresty:latest | ||
RUN apt-get update && apt-get install -y wget | ||
|
||
# ENV DOCKERIZE_VERSION v0.6.1 | ||
# RUN wget https://github.com/jwilder/dockerize/releases/download/$DOCKERIZE_VERSION/dockerize-linux-amd64-$DOCKERIZE_VERSION.tar.gz \ | ||
# && tar -C /usr/local/bin -xzvf dockerize-linux-amd64-$DOCKERIZE_VERSION.tar.gz \ | ||
# && rm dockerize-linux-amd64-$DOCKERIZE_VERSION.tar.gz | ||
|
||
WORKDIR /app | ||
EXPOSE 80 | ||
ADD ./system.conf /etc/nginx/templates/system.conf.template | ||
ADD ./app.conf /etc/nginx/templates/app.conf.template | ||
ADD ./scripts /scripts | ||
|
||
ADD ./dist /app/ | ||
|
||
CMD [ "sh", "/scripts/start.sh" ] |
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,66 @@ | ||
|
||
# for app service | ||
server { | ||
listen 80; | ||
server_name ${DEPLOY_DOMAIN}; | ||
client_max_body_size 0; | ||
|
||
location / { | ||
|
||
# Allow CORS | ||
add_header Access-Control-Allow-Origin *; | ||
add_header Access-Control-Allow-Methods GET,POST,PUT,DELETE,PATCH,OPTIONS; | ||
add_header Access-Control-Allow-Headers *; | ||
add_header Access-Control-Expose-Headers *; | ||
add_header Access-Control-Max-Age 3600; | ||
|
||
if ($request_method = 'OPTIONS') { | ||
return 204; | ||
} | ||
|
||
# Resolve app service | ||
resolver 127.0.0.11; | ||
if ($host ~* "(\w{8}(-\w{4}){3}-\w{12})\.(.+)$") { | ||
set $appid $1; | ||
set $service_id app_$appid; | ||
} | ||
|
||
proxy_pass http://$service_id:8000; | ||
add_header appid $appid; | ||
proxy_read_timeout 600s; | ||
proxy_set_header Host $host; | ||
proxy_http_version 1.1; | ||
|
||
# Upgrade websocket | ||
proxy_set_header Upgrade $http_upgrade; | ||
proxy_set_header Connection "upgrade"; | ||
|
||
|
||
# Logging | ||
log_by_lua_block { | ||
ngx.log(ngx.ERR, ngx.var.appid, ',', ngx.var.service_id, ',', ngx.var.request_uri, ',') | ||
} | ||
} | ||
|
||
location /deploy/incoming { | ||
# Allow CORS | ||
add_header Access-Control-Allow-Origin *; | ||
add_header Access-Control-Allow-Methods GET,POST,PUT,DELETE,PATCH,OPTIONS; | ||
add_header Access-Control-Allow-Headers *; | ||
add_header Access-Control-Expose-Headers *; | ||
add_header Access-Control-Max-Age 3600; | ||
|
||
if ($request_method = 'OPTIONS') { | ||
return 204; | ||
} | ||
|
||
if ($host ~* "(\w{8}(-\w{4}){3}-\w{12})\.(.+)$") { | ||
set $appid $1; | ||
proxy_pass http://system_server:9000/apps/$appid/deploy/incoming; | ||
add_header appid $appid; | ||
} | ||
|
||
proxy_send_timeout 600s; | ||
proxy_read_timeout 600s; | ||
} | ||
} |
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,10 @@ | ||
{ | ||
"name": "gateway", | ||
"version": "0.6.12", | ||
"description": "", | ||
"main": "index.js", | ||
"private": true, | ||
"scripts": { | ||
}, | ||
"author": "Maslow(wangfugen@126.com)" | ||
} |
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,32 @@ | ||
#!/bin/sh | ||
|
||
set -e | ||
|
||
ME=$(basename $0) | ||
|
||
auto_envsubst() { | ||
local template_dir="${NGINX_ENVSUBST_TEMPLATE_DIR:-/etc/nginx/templates}" | ||
local suffix="${NGINX_ENVSUBST_TEMPLATE_SUFFIX:-.template}" | ||
local output_dir="${NGINX_ENVSUBST_OUTPUT_DIR:-/etc/nginx/conf.d}" | ||
|
||
local template defined_envs relative_path output_path subdir | ||
defined_envs=$(printf '${%s} ' $(env | cut -d= -f1)) | ||
[ -d "$template_dir" ] || return 0 | ||
if [ ! -w "$output_dir" ]; then | ||
echo "$ME: ERROR: $template_dir exists, but $output_dir is not writable" | ||
return 0 | ||
fi | ||
find "$template_dir" -follow -type f -name "*$suffix" -print | while read -r template; do | ||
relative_path="${template#$template_dir/}" | ||
output_path="$output_dir/${relative_path%$suffix}" | ||
subdir=$(dirname "$relative_path") | ||
# create a subdirectory where the template file exists | ||
mkdir -p "$output_dir/$subdir" | ||
echo "$ME: Running envsubst on $template to $output_path" | ||
envsubst "$defined_envs" < "$template" > "$output_path" | ||
done | ||
} | ||
|
||
auto_envsubst | ||
|
||
exit 0 |
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,5 @@ | ||
#! /bin/sh | ||
|
||
sh /scripts/auto_envsubst.sh | ||
|
||
/usr/bin/openresty -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,18 @@ | ||
|
||
# for system client & server | ||
server { | ||
listen 80; | ||
server_name localhost ${SYS_CLIENT_HOST}; | ||
client_max_body_size 0; | ||
|
||
root /app; | ||
location / { | ||
index index.html index.htm; | ||
} | ||
|
||
location /sys-api/ { | ||
proxy_pass http://system_server:9000/; | ||
proxy_send_timeout 600s; | ||
proxy_read_timeout 600s; | ||
} | ||
} |
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