Initial dev deployment [infra]
This commit is contained in:
@@ -1,25 +1,26 @@
|
||||
#!/bin/sh
|
||||
set -eu
|
||||
|
||||
replace_env_var() {
|
||||
local var_name=$1
|
||||
local placeholder="%%$var_name%%"
|
||||
local value=$(eval echo \$$var_name)
|
||||
# inject value to the index.html
|
||||
sed -i "s|$placeholder|$value|g" /usr/share/pweb/index.html
|
||||
js_escape() {
|
||||
printf '%s' "$1" | sed 's/\\/\\\\/g; s/"/\\"/g'
|
||||
}
|
||||
|
||||
echo "Starting Container"
|
||||
write_app_config() {
|
||||
cat <<EOF >/usr/share/pweb/app-config.js
|
||||
window.appConfig = {
|
||||
apiProto: "$(js_escape "${API_PROTOCOL:-https}")",
|
||||
apiHost: "$(js_escape "${SERVICE_HOST:-app.sendico.io}")",
|
||||
apiEndpoint: "$(js_escape "${API_ENDPOINT:-/api/v1}")",
|
||||
amplitudeSecret: "$(js_escape "${AMPLITUDE_SECRET:-}")",
|
||||
defaultLocale: "$(js_escape "${DEFAULT_LOCALE:-en}")",
|
||||
defaultCurrency: "$(js_escape "${DEFAULT_CURRENCY:-EUR}")",
|
||||
wsProto: "$(js_escape "${WS_PROTOCOL:-wss}")",
|
||||
wsEndpoint: "$(js_escape "${WS_ENDPOINT:-/ws}")"
|
||||
};
|
||||
EOF
|
||||
}
|
||||
|
||||
replace_env_var "WS_PROTOCOL"
|
||||
replace_env_var "WS_ENDPOINT"
|
||||
replace_env_var "API_PROTOCOL"
|
||||
replace_env_var "SERVICE_HOST"
|
||||
replace_env_var "API_ENDPOINT"
|
||||
replace_env_var "AMPLITUDE_SECRET"
|
||||
replace_env_var "DEFAULT_LOCALE"
|
||||
replace_env_var "DEFAULT_CURRENCY"
|
||||
echo "Starting container"
|
||||
write_app_config
|
||||
|
||||
echo "Passing by launch command"
|
||||
# Execute the passed command (e.g., starting Caddy)
|
||||
# exec "$@"
|
||||
exec caddy run --config /etc/caddy/Caddyfile --adapter caddyfile
|
||||
|
||||
@@ -33,6 +33,7 @@
|
||||
<link rel="manifest" href="manifest.json">
|
||||
</head>
|
||||
<body>
|
||||
<script src="app-config.js"></script>
|
||||
<script src="flutter_bootstrap.js" async></script>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
Reference in New Issue
Block a user