-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Dynamically set production app container config in entrypoint (#605)
* Add entrypoint script that dynamically sets vue args post-build in docker prod containers * Update CI config for new production vars * Update e2e tests to catch case where API cannot be reached * Install `serve` as a real JS dependency rather than ad hoc server build installation * Add .dockerignore to avoid pulling tests and errant node modules into containers * Update PATH in Docker file to accommodate for local install of serve * Better warnings when production container is ill-configured * Trigger `.env` reading by listing field names in `environment`
- Loading branch information
Showing
9 changed files
with
325 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
#!/bin/sh | ||
|
||
# Patch the built app to use the specified environment variables | ||
# at runtime, then serve the app | ||
# | ||
# See https://stackoverflow.com/questions/53010064/pass-environment-variable-into-a-vue-app-at-runtime for inspiration. | ||
# | ||
set -e | ||
ROOT_DIR=/app/dist | ||
|
||
if [ -z "$VUE_APP_API_URL" ]; then | ||
echo "VUE_APP_API_URL is unset and we are in production mode. Exiting." | ||
echo "" | ||
echo "Found settings:" | ||
echo "" | ||
env | ||
echo "" | ||
exit 1 | ||
fi | ||
|
||
echo "Replacing env vars in Javascript files" | ||
echo "Settings:" | ||
echo "" | ||
echo " API_URL: ${VUE_APP_API_URL}" | ||
echo " LOGO_URL: ${VUE_APP_LOGO_URL}" | ||
echo " HOMEPAGE_URL: ${VUE_APP_HOMPAGE_URL}" | ||
echo "" | ||
echo "Patching..." | ||
|
||
for file in $ROOT_DIR/js/app.*.js*; do | ||
echo "$file" | ||
sed -i "s|magic-api-url|${VUE_APP_API_URL}|g" $file | ||
sed -i "s|magic-logo-url|${VUE_APP_LOGO_URL}|g" $file | ||
sed -i "s|magic-homepage-url|${VUE_APP_HOMEPAGE_URL}|g" $file | ||
done | ||
|
||
echo "Done!" | ||
|
||
serve -s ${ROOT_DIR} -p 8081 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
**/node_modules | ||
**/cypress | ||
**/.env* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.