-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: add runtime publicpath and switch to nginx (#6)
* feat: add runtime publicpath and switch to nginx * chore: add remote 2 and namespace runtime env
- Loading branch information
Showing
12 changed files
with
115 additions
and
40 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 was deleted.
Oops, something went wrong.
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 |
---|---|---|
@@ -1,9 +1,9 @@ | ||
#!/bin/sh | ||
|
||
# Run the script before starting the server | ||
sh /createJSONConfig.sh | ||
sh /createRemoteConfig.sh | ||
sh /loadRuntimeConfig.sh | ||
sh /usr/share/nginx/html/createJSONConfig.sh | ||
sh /usr/share/nginx/html/createRemoteConfig.sh | ||
sh /usr/share/nginx/html/loadRuntimeConfig.sh | ||
|
||
# This will exec the CMD from your Dockerfile, i.e. "npm start" | ||
exec "$@" |
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 |
---|---|---|
@@ -1,5 +1,12 @@ | ||
#!/bin/bash | ||
sed -i 's#__REMOTE_1_URL__#'"$REMOTE_1_URL"'#g' runtime-env.js | ||
sed -i 's#__REMOTE_1_URL__#'"$REMOTE_1_URL"'#g' index.html | ||
sed -i 's#__REMOTE_1_URL__#'"$REMOTE_1_URL"'#g' /usr/share/nginx/html/runtime-env.js | ||
sed -i 's#__REMOTE_1_URL__#'"$REMOTE_1_URL"'#g' /usr/share/nginx/html/index.html | ||
|
||
sed -i 's#__REMOTE_2_URL__#'"$REMOTE_2_URL"'#g' /usr/share/nginx/html/runtime-env.js | ||
sed -i 's#__REMOTE_2_URL__#'"$REMOTE_2_URL"'#g' /usr/share/nginx/html/index.html | ||
|
||
sed -i 's#__PUBLIC_PATH__#'"$PUBLIC_PATH"'#g' /usr/share/nginx/html/index.html | ||
sed -i 's#__PUBLIC_PATH__#'"$PUBLIC_PATH"'#g' /usr/share/nginx/html/main.js | ||
|
||
exec "$@" | ||
|
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,64 @@ | ||
# auto detects a good number of processes to run | ||
worker_processes auto; | ||
|
||
#Provides the configuration file context in which the directives that affect connection processing are specified. | ||
events { | ||
# Sets the maximum number of simultaneous connections that can be opened by a worker process. | ||
worker_connections 8000; | ||
# Tells the worker to accept multiple connections at a time | ||
multi_accept on; | ||
} | ||
|
||
|
||
http { | ||
# what times to include | ||
include /etc/nginx/mime.types; | ||
# what is the default one | ||
default_type application/octet-stream; | ||
|
||
# Sets the path, format, and configuration for a buffered log write | ||
log_format compression '$remote_addr - $remote_user [$time_local] ' | ||
'"$request" $status $upstream_addr ' | ||
'"$http_referer" "$http_user_agent"'; | ||
|
||
server { | ||
# listen on port 8080 | ||
listen 8080; | ||
|
||
gzip on; | ||
gzip_types text/plain application/xml text/css application/javascript; | ||
gzip_proxied no-cache no-store private expired auth; | ||
gzip_min_length 1000; | ||
|
||
# where the root here | ||
root /usr/share/nginx/html; | ||
# what file to server as index | ||
index index.html index.htm; | ||
|
||
location / { | ||
# First attempt to serve request as file, then | ||
# as directory, then fall back to redirecting to index.html | ||
try_files $uri $uri/ /index.html; | ||
} | ||
|
||
# Media: images, icons, video, audio, HTC | ||
location ~* \.(?:jpg|jpeg|gif|png|ico|cur|gz|svg|svgz|mp4|ogg|ogv|webm|htc)$ { | ||
expires 1M; | ||
access_log off; | ||
add_header Cache-Control "public"; | ||
} | ||
|
||
# Javascript and CSS files | ||
location ~* \.(?:css|js)$ { | ||
try_files $uri =404; | ||
expires 1y; | ||
access_log off; | ||
add_header Cache-Control "public"; | ||
} | ||
|
||
# Any route containing a file extension (e.g. /devicesfile.js) | ||
location ~ ^.+\..+$ { | ||
try_files $uri =404; | ||
} | ||
} | ||
} |
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 @@ | ||
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
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 |
---|---|---|
@@ -1,5 +1,5 @@ | ||
// public/env.js | ||
// https://medium.com/@hasniarif/how-to-handle-runtime-environment-variables-with-react-ec809cb07831 | ||
window.env = { | ||
window.shellEnv = { | ||
REMOTE_1_URL: '__REMOTE_1_URL__', | ||
REMOTE_2_URL: '__REMOTE_2_URL__', | ||
}; |