Last active
July 28, 2020 17:44
-
-
Save christopherdeutsch/3a4d1ee506313b65607cb0959514883a to your computer and use it in GitHub Desktop.
webpack cache-at-build-time Dockerfile example
This file contains hidden or 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
| #!/bin/bash | |
| # read in WEBPACK_BUILD_ENV that was written at build time in the Dockerfile (above) | |
| . /webpack-environment.env | |
| if [[ "$1" = "myapp" ]]; then | |
| if [[ -z "$ENV" || "$WEBPACK_BUILD_ENV" != "$ENV" ]]; then | |
| npm run "build:${environment}" | |
| fi | |
| exec myapp | |
| fi | |
| exec "$@" |
This file contains hidden or 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
| # build webpack at runtime and write the build envionment name to a file | |
| FROM whatever | |
| ARG WEBPACK_BUILD_ENV=dev | |
| RUN npm run build:${WEBPACK_BUILD_ENV && echo ${WEBPACK_BUILD_ENV} > /webpack-environment.env | |
| ENTRYPOINT ["/docker-entrypoint.sh"] | |
| CMD ["myapp"] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment