-
Notifications
You must be signed in to change notification settings - Fork 96
Expand file tree
/
Copy pathdocker-entrypoint.sh
More file actions
executable file
·40 lines (33 loc) · 1.55 KB
/
docker-entrypoint.sh
File metadata and controls
executable file
·40 lines (33 loc) · 1.55 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
#!/bin/sh
set -e
cp -rv /opt/ui/dist/* /var/www
echo "running with UI_PATH=${UI_PATH}"
if [[ ! -z "$BASE_URL_OVERRIDE" ]]; then
echo "running with BASE_URL=${BASE_URL_OVERRIDE}"
sed -i "s^{PLACEHOLDER_BASE_URL}^$BASE_URL_OVERRIDE^g" /var/www/*.js
else
echo "running with BASE_URL=${BASE_URL}"
sed -i "s^{PLACEHOLDER_BASE_URL}^$BASE_URL^g" /var/www/*.js
fi
# export your OPENCOST_FOOTER_CONTENT='<a href="https://opencost.io">OpenCost</a>' in your Dockerfile to set
if [[ ! -z "$OPENCOST_FOOTER_CONTENT" ]]; then
sed -i "s^PLACEHOLDER_FOOTER_CONTENT^$OPENCOST_FOOTER_CONTENT^g" /var/www/*.js
else
sed -i "s^PLACEHOLDER_FOOTER_CONTENT^OpenCost version: $VERSION ($HEAD)^g" /var/www/*.js
fi
# Custom aggregation options: JSON object (map string:string), e.g. {"Label: team":"label:team"}
if [[ ! -z "$CUSTOM_AGGREGATION_OPTIONS" ]]; then
echo "injecting CUSTOM_AGGREGATION_OPTIONS"
esc=$(printf '%s' "$CUSTOM_AGGREGATION_OPTIONS" | sed 's/\\/\\\\/g; s/&/\\&/g; s/"/\\"/g')
sed -i "s^PLACEHOLDER_CUSTOM_AGGREGATIONS^$esc^g" /var/www/*.js
else
sed -i "s^PLACEHOLDER_CUSTOM_AGGREGATIONS^{}^g" /var/www/*.js
fi
if [[ ! -e /etc/nginx/conf.d/default.nginx.conf ]];then
envsubst '$API_PORT $API_SERVER $UI_PORT $UI_PATH $BASE_URL $PROXY_CONNECT_TIMEOUT $PROXY_SEND_TIMEOUT $PROXY_READ_TIMEOUT' \
< /etc/nginx/conf.d/default.nginx.conf.template \
> /etc/nginx/conf.d/default.nginx.conf
fi
echo "Starting OpenCost UI version $VERSION ($HEAD)"
# Run the parent (nginx) container's entrypoint script
exec /docker-entrypoint.sh "$@"