DockerEntrypoint
- Example entry point file
- It creates a env.js file form environment variables - for use with SPA react/angular for runtime config
Add to Dockerfile as
COPY Dockerentrypoint.sh /Dockerentrypoint.sh ENTRYPOINT [ "/Dockerentrypoint.sh" ]
- at the last line it executes Docker CMD passed to docker
# Container startups script. # Allow for runtime configuration through env vars. # https://12factor.net/build-release-run set -e echo "# Start container with $0 PWD=${PWD}" echo "#" echo "# cat .version.txt" cat .version.txt echo "#" echo "# Add env vars REACT_APP_* to ''env.js'' at webserver root" echo "window.ENV = `jo -p \`env | grep REACT_APP_ | sed -e 's/[[:blank:]]/{_!!_}/g'\` end=1`" | sed -e 's/{_!!_}/ /g' | tee env.js echo "#" echo "# Starting docker cmd \$@=$@ ..." exec "$@"