mirror of
https://github.com/sartography/cr-connect-bpmn.git
synced 2025-01-11 17:44:32 +00:00
Substitutes environment variables in multiple files
This commit is contained in:
parent
9d28a472a5
commit
d6850f056c
@ -22,11 +22,8 @@ COPY --from=builder /crc-bpmn/nginx.conf /etc/nginx/conf.d/default.conf
|
||||
COPY ./docker/substitute-env-variables.sh ./entrypoint.sh
|
||||
RUN chmod +x ./entrypoint.sh
|
||||
|
||||
# Substitute environment variables in nginx configuration
|
||||
CMD ["./entrypoint.sh", "/etc/nginx/conf.d/default.conf"]
|
||||
|
||||
# Substitute environment variables in index.html
|
||||
ENTRYPOINT ["./entrypoint.sh", "/usr/share/nginx/html/index.html"]
|
||||
# Substitute environment variables in nginx configuration and index.html
|
||||
ENTRYPOINT ["./entrypoint.sh", "/usr/share/nginx/html/index.html,/etc/nginx/conf.d/default.conf"]
|
||||
|
||||
### STAGE 3: Profit! ###
|
||||
CMD ["nginx", "-g", "daemon off;"]
|
||||
|
20
docker/substitute-env-variables.sh
Normal file → Executable file
20
docker/substitute-env-variables.sh
Normal file → Executable file
@ -1,18 +1,22 @@
|
||||
#!/bin/bash
|
||||
|
||||
# The first parameter is the path to the file which should be substituted
|
||||
# The first parameter is a comma-delimited list of paths to files which should be substituted
|
||||
if [[ -z $1 ]]; then
|
||||
echo 'ERROR: No target file given.'
|
||||
echo 'ERROR: No target files given.'
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Replace strings in the given file that have the format ${ENV_VAR}
|
||||
envsubst '\$PRODUCTION \$API_URL \$IRB_URL \$PORT0' < "$1" > "$1".tmp && mv "$1".tmp "$1"
|
||||
env_list='\$PRODUCTION \$API_URL \$IRB_URL \$HOME_ROUTE \$PORT0'
|
||||
for i in $(echo $1 | sed "s/,/ /g")
|
||||
do
|
||||
# Replace strings in the given file(s) in env_list
|
||||
envsubst "$env_list" < "$i" > "$i".tmp && mv "$i".tmp "$i"
|
||||
|
||||
# Set DEBUG=true in order to log the replaced file
|
||||
if [ "$DEBUG" = true ] ; then
|
||||
exec cat $1
|
||||
fi
|
||||
# Set DEBUG=true in order to log the replaced file
|
||||
if [ "$DEBUG" = true ] ; then
|
||||
exec cat $i
|
||||
fi
|
||||
done
|
||||
|
||||
# Execute all other commands with parameters
|
||||
exec "${@:2}"
|
||||
|
Loading…
x
Reference in New Issue
Block a user