JSPM

  • Created
  • Published
  • Downloads 58599
  • Score
    100M100P100Q197844F
  • License ISC

envsub is envsubst for NodeJS

Package Exports

  • envsub

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (envsub) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

envsub is envsubst for NodeJS

NodeJS command line module providing environment variable substitution via Handlebars

npm install -g envsub
envsub templateFile outputFile

Example

  • Ensure environment variables exist
export MY_NAME=daniel
  • Create an environment variable template

template.html

Hello my name is {{ MY_NAME }}

  • Execute envsub
envsub template.html output.html
  • And the result

output.html

Hello my name is daniel

Docker

envsubst is officially recognised by NGINX as a suitable NGINX config templating solution.

This module seeks to make envsubst freely available to the Node community for Docker templating.

In your Dockerfile

FROM node
RUN npm install -g envsub

Now you can use envsub in your Dockerfile with RUN envsub templateFile outputFile for templating at build time

docker build --build-arg MY_NAME=daniel -t imagename .

Or at run time typically using an ENTRYPOINT script

docker run -dit --env MY_NAME=daniel imagename

View Source

The codebase is intentionally simple and does exactly what you would expect.

View source HERE