Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remote Containers - Allow to specify --project-directory for docker-compose #2323

Open
deltoss opened this issue Feb 9, 2020 · 1 comment
Assignees
Labels
containers Issue in vscode-remote containers feature-request Request for new features or functionality plan-review PM-highlighted item determined to be P1 or P2

Comments

@deltoss
Copy link

deltoss commented Feb 9, 2020

Hi, I like the idea of Remote - Containers. I'm making examples to understand and see how things work with this extension.

I've tried following the steps with Connecting to Multiple Containers at Once, with my own twists where I tried to use a shared .env file.

The Problem

I have this structure:

  • .docker
  • WebApi
    • .devcontainer.json
    • ... Other source code files
  • WebApp
    • .devcontainer.json
    • ... Other source code files
  • .env
  • docker-compose.base.yml
  • docker-compose.devcontainer.yml
  • docker-compose.release.yml

With the remote - containers extension, if you follow the official instructions here, where you'd use the command Remote-Containers: Open Folder in Container..., it won't actually work and would just error out. The problem is it'll open the folder where the .devcontainer.json file resides. The docker-compose command's working directory would also be where this .devcontainer.json file resides.

The implications of this is it'll try to find and use the .env file from the directory where the .devcontainer.json file resides (which of course, doesn't exists). As it doesn't exist in that directory, the .env file isn't used, meaning the environment variables doesn't get imported, causing the extension to fail.

To reproduce this issue, you can clone my example repo, then remove the two .env (i.e. WebApp/.env & WebApi/.env) files, and then follow the README instructions.

Workaround

Thus, currently the only way to get it to work is you'll need to copy your .env file to be where the .devcontainer.json file resides. That is, you'd have the below structure where you .env file is duplicated.

  • .docker
  • WebApi
    • .devcontainer.json
    • .env
    • ... Other source code files
  • WebApp
    • .devcontainer.json
    • .env
    • ... Other source code files
  • docker-compose.base.yml
  • docker-compose.devcontainer.yml
  • docker-compose.release.yml

This isn't really an ideal solution as you'd duplicate the .env file multiple times, needing to maintain all of them.

To reproduce this workaround, you can clone my example repo and then follow the README instructions.

Possible Solution

This can be resolved if the extension lets us somehow specify the option --project-directory for docker-compose, perhaps in the .devcontainer.

For more information on --project-directory, see:

@deltoss deltoss changed the title Remote Containers - Remote Containers - Allow to specify --project-directory for Docker-Compose Feb 9, 2020
@deltoss deltoss changed the title Remote Containers - Allow to specify --project-directory for Docker-Compose Remote Containers - Allow to specify --project-directory for docker-compose Feb 9, 2020
@egamma egamma added the containers Issue in vscode-remote containers label Feb 11, 2020
@chrmarti chrmarti added the feature-request Request for new features or functionality label Feb 18, 2020
@MisterGlass
Copy link

I have a similar requirement, in order to do builds in our monorepo (shared libraries are in a sibling folder).

A setting in the .devcontainer file would be perfect, and there are equivalent settings for build context when using a dockerfile instead of a compose file.

@bamurtaugh bamurtaugh added the plan-review PM-highlighted item determined to be P1 or P2 label Nov 20, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
containers Issue in vscode-remote containers feature-request Request for new features or functionality plan-review PM-highlighted item determined to be P1 or P2
Projects
None yet
Development

No branches or pull requests

5 participants