Externalise and Configure Frontend Environment Variables on Kubernetes

Build Once, Run Anywhere

Background

Pre-requisites

Vue’s way for handling env variables…

Problem

Idea Overview

Detailed Steps

public/env-config.js
public/index.html (Line 8)
Reference variables in code (Line 42)
generate_env-config.sh
docker_entrypoint.sh
Multi-stage builds — With generating env-config.js
Injecting VUE_APP_FOO=”docker_foo” on localhost:5000
docker build -t vue-env-sample:1 .
docker run -p 5000:5000 -e VUE_APP_FOO="docker_foo" vue-env-sample:1
Kubernetes deployment yaml sample

Conclusion

Acknowledgements

A BIG THANK YOU to my developer friends!

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store