Previous post: A Unified Development Environment Journey - Part 1
I won’t mention about setting up Codespaces or Devcontainer as it’s already on their documentation page. In this post, I’ll show you some of the problems and example workflows that I did with Codespaces/Devcontainer.
Dev credentials and Environment variables
Your organization may created some private packages that requires some layers of authentication in order to install (the npm packages hosted on GCP for example). One possible solution is to create an access token (or any other type of credential) and put set it in your development environment. For Codespaces, you can simply set it on your Github configuration page. However, for Devcontainer, it needs a bit more work. The idea is to mount the environment file from outside of the container and then load those variables to Devcontainer
Create an env file on your computer, for example /var/devcontainer-mount/workflow.env
, which
contains all the secrets that you want to inject
export GOOGLE_APPLICATION_CREDENTIALS="xxx"
Mount the folder to your Devcontainer by adding a mount volume to your devcontainer.json file. Read more here Add another local file mount
{
//...other config
"mounts": [
{
"source": "/var/devcontainer-mount",
"target": "/workspaces/devcontainer-mount",
"type": "bind"
}
]
}