Skip to content

dabeck/envsubst

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

envsubst Dockerfile

Docker Repository on Quay

This image will process a filename which is passed as an argument and substitute $FOO placeholders with ENVIRONMENT VARIABLE values. A new file of the same name is written to the /processed directory.

local example:

docker build -t envsubst .

docker run --rm -v $(pwd)/workdir:/workdir -v $(pwd)/processed:/processed -e "VAR_1=A" -e "VAR_2=b" dibi/envsubst:latest

This can be useful when running on Kubernetes and you wish to update placeholders in config files.

This image can run as an init-container after mounting a configmap into /workdir. Because config map files are readonly you'll also need to mount an emptyDir: {} volume to the init-container /processed folder as well as in the main pod container where you wish your new config to be mounted.

An example:

[...]
spec:
  replicas: 1
  template:
    spec:
      containers:
      - name: myContainer
        image: alpine
        volumeMounts:
        - name: config
          mountPath: /config
      initContainers:
      - name: init-config
        image: dibi/envsubst
        env:
        - name: mySecretVar
          valueFrom:
            secretKeyRef:
              name: mySecret
              key: key
        volumeMounts:
        - name: config
          mountPath: /processed
        - name: workdir
          mountPath: /workdir
      volumes:
      - name: workdir
        configMap:
          name: myConfigMap
      - name: config
        emptyDir: {}

About

docker image to replace placeholders in a file with env var values

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Shell 80.2%
  • Dockerfile 19.8%