'Configuring environment variables prior to creation of dev container

I am trying to integrate the Remote - Containers with my docker-compose.yaml.

However, my compose file is making use of the variable substitution feature.

services:
    command: yarn server
    environment:
        MONGO_URI: mongodb://database:27017/todo
    ports:
        - ${SERVER_PORT}:3000
        - ${SERVER_DEBUG_PORT}:9320

Typically I set these variables from a Makefile that wraps the docker-compose commands I run to start my development environment.

How can I set these environment variables before the extension creates the Dev Container via docker-compose?

I've attempted to use the initializeCommand in the following ways.

devcontainer.json

"initializeCommand": ". ./env.sh"
"initializeCommand": "source env.sh"

I also attempted to use remoteEnv in the devcontainer.json.

I also attempted to set settings.terminal.integrated.env.linux.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source