mirror of
https://github.com/netbymatt/ws4kp.git
synced 2026-04-14 07:39:29 -07:00
env workaround for static build
This commit is contained in:
@@ -10,6 +10,10 @@ RUN npm run build
|
||||
RUN rm dist/playlist.json
|
||||
|
||||
FROM nginx:alpine
|
||||
|
||||
COPY static-env-handler.sh /docker-entrypoint.d/01-static-env-handler.sh
|
||||
RUN chmod +x /docker-entrypoint.d/01-static-env-handler.sh
|
||||
|
||||
COPY --from=node-builder /app/dist /usr/share/nginx/html
|
||||
COPY nginx.conf /etc/nginx/conf.d/default.conf
|
||||
CMD ["nginx", "-g", "daemon off;"]
|
||||
|
||||
@@ -126,6 +126,8 @@ Environment variables can be added to the command line as usual, or via a .env f
|
||||
|
||||
Environment variables that are to be added to the default query string are prefixed with `WSQS_` and then use the same key/value pairs generated by the [Permalink](#sharing-a-permalink-bookmarking) above, with the `- (dash)` character replaced by an `_ (underscore)`. For example, if you wanted to turn the travel forecast on, you would find `travel-checkbox=true` in the permalink, its matching environment variable becomes `WSQS_travel_checkbox=true`.
|
||||
|
||||
When using the Docker container, these environment variables are read on container start-up to generate the static redirect HTML.
|
||||
|
||||
## Music
|
||||
The WeatherStar had wonderful background music from the smooth jazz and new age genres by artists of the time. Lists of the music that played are available by searching online, but it's all copyrighted music and would be difficult to provide as part of this repository.
|
||||
|
||||
@@ -165,6 +167,8 @@ Thanks to the WeatherStar community for providing these discussions to further e
|
||||
## Customization
|
||||
A hook is provided as `/server/scripts/custom.js` to allow customizations to your own fork of this project, without accidentally pushing your customizations back upstream to the git repository. A sample file is provided at `/server/scripts/custom.sample.js` and should be renamed to `custom.js` activate it.
|
||||
|
||||
When using Docker, mount your `custom.js` file to `/usr/share/nginx/html/scripts/custom.js` to customize the static build.
|
||||
|
||||
## Issue reporting and feature requests
|
||||
|
||||
Please do not report issues with api.weather.gov being down. It's a new service and not considered fully operational yet. I've also observed that the API can go down on a regional basis (based on NWS office locations). This means that you may have problems getting data for, say, Chicago right now, but Dallas and others are working just fine.
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
server {
|
||||
listen 80;
|
||||
listen 8080;
|
||||
server_name localhost;
|
||||
|
||||
root /usr/share/nginx/html;
|
||||
|
||||
location / {
|
||||
index index.html index.htm;
|
||||
index redirect.html index.html index.htm;
|
||||
try_files $uri $uri/ =404;
|
||||
}
|
||||
|
||||
|
||||
39
static-env-handler.sh
Normal file
39
static-env-handler.sh
Normal file
@@ -0,0 +1,39 @@
|
||||
#!/bin/sh
|
||||
set -eu
|
||||
|
||||
ROOT="/usr/share/nginx/html"
|
||||
QS=""
|
||||
|
||||
# build query string from WSQS_ env vars
|
||||
for var in $(env); do
|
||||
case "$var" in
|
||||
WSQS_*=*)
|
||||
key="${var%%=*}"
|
||||
val="${var#*=}"
|
||||
key="${key#WSQS_}"
|
||||
key="${key//_/-}"
|
||||
if [ -n "$QS" ]; then
|
||||
QS="$QS&${key}=${val}"
|
||||
else
|
||||
QS="${key}=${val}"
|
||||
fi
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
|
||||
if [ -n "$QS" ]; then
|
||||
cat > "$ROOT/redirect.html" <<EOF
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<title>Redirecting</title>
|
||||
<meta http-equiv="refresh" content="0;url=/index.html?$QS" />
|
||||
</head>
|
||||
<body></body>
|
||||
</html>
|
||||
EOF
|
||||
fi
|
||||
|
||||
exec nginx -g 'daemon off;'
|
||||
Reference in New Issue
Block a user