Using Doppler + vscode + dev container + docker-compose

Hi! I have trouble setting up these things. I have a project with .devcontainer. Remote container is build from docker-compose.yml (something like this - example). I found this video - How To Use Visual Studio Dev Containers To Develop Node.js Apps Remotely on AWS but in this tutorial they use plain Dockerfile. I need to run additional services in docker-compose.yml, and configure them using env variables from doppler while building vscode dev container. How do I achieve this? Thanks!

Hey Eugene and welcome to the Doppler community!

We don’t yet have a dev container example using Docker Compose but before getting to that, are you using the Doppler CLI with Docker Compose locally to run your application?

If so, all you should theoretically need to do is populate the required DOPPLER_TOKEN environment variable in the VS Code process that will be spawning docker-compose and your dev container.

That can then be made available to your dev container by configuring the containerEnv property in your devcontainer.json file to pull DOPPLER_TOKEN from the VS Code process:

"containerEnv": {
    "DOPPLER_PROJECT": "your-project",
    "DOPPLER_CONFIG": "dev",
    "DOPPLER_TOKEN": "${localEnv:DOPPLER_TOKEN}", 
}

The easiest method of populating the DOPPLER_TOKEN environment variable is by launching your dev container using the devcontainer CLI:

DOPPLER_TOKEN="$(doppler configure get token --plain)" devcontainer open ~/Projects/your-applcation

Let me know how you go!

Thanks for your answer, Ryan. I achieved my goal with devcontainer CLI:

doppler run -- devcontainer open ~/source/my-folder

Excellent @eugene!

Love it when a plan comes together!

1 Like