microsoft / microsoft/vscode-remote-release

Provide build arguments for docker-compose in docker-compose.yml setups

Open
#6,516 4 comments 26 reactions 1 assignee View on GitHub

@chrmarti is already working on this.

Since Mar 29, 2022.

containers feature-request
Dominant language
Dockerfile
Stars
4.2k
Forks
470
Avg merge
1d 1h
Merged PRs (30d)
1

Description

Hi. There's an issue right now with VSCode on MacOS where environment variables are not loaded from the default system shell when VSCode is launched from the dock, likely because VSCode launches with posix_spawn() which doesn't use the system shell. https://github.com/microsoft/vscode/issues/118460

We're looking into using devcontainers for our development workflow as it brings a lot of benefits, the biggest being quick access to the container's shell during development directly through a VSCode terminal without having to run docker commands.

The problem is that we have submitted our .env file into our Git repository for our codebase because it provides some sane default build arguments for docker-compose that should be enabled for all developers. We have a separate workflow for storing secrets for our Docker image build arguments. Usually this means storing secrets in a file called .env.development.local. In a regular docker-compose set up this wouldn't be a problem as we can just provide a --env-file.

Unfortunately, we can't use the --env-file flag in the devcontainer build process because there's no way of specifying this in the devcontainer.json file.

Here's what the command looks like in my machine during a devcontainer setup:

[716 ms] Start: Run: docker-compose --project-name backend -f /Users/dimgl/dev/backend/docker-compose.yml -f /Users/dimgl/dev/backend/.devcontainer/docker-compose.yml build --no-cache --pull db redis app

Here we would put a --env-file .env.development.local file to send in secrets. So we'd like to be able to do something like this:

{
  "dockerComposeFile": [
    "../docker-compose.yml",
    "docker-compose.yml"
  ],
  "buildArgs": [
    "--env-file",
    ".env.development.local"
  ]
}

Thanks.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.