Configuring access to private repositories in devcontainers
Asked Answered
D

1

6

I would like to start using devcontainers (Visual Studio Code - Remote Containers) on some internal projects. These projects all need access to internal package repositories (npm, maven, nuget, docker, apt, yum etc.) during their build, which generally requires providing appropriate config files (~/.npmrc, ~/.m2/settings.xml, ~/.config/NuGet/NuGet.Config, /etc/apt/sources.list etc.).

Now for convenience it might be easiest to just embed the necessary configs into the base image, but I don't want everybody to just use the same credentials, nor do I want to have the credentials stored in a base image somewhere.

VSCode automatically supports forwarding git-credential-helper and ssh-agent, and copies .gitconfig by default, but not for other tools. It also provides a way to check out additional “dotfiles” repository into the container and run a script, but again, repository is not the right tool here.

Are there better options for injecting tool credentials into a devcontainer that are not too configuration-intensive for the team members while still using their own credentials?

Diesel answered 27/10, 2021 at 12:8 Comment(4)
Did you work out a solution for this?Boethius
@GaTechThomas, no, I didn't. The easiest is probably to use environment variables with credentials and tell everybody to set them, but it's not very user-friendly.Diesel
Solution can be found at liammartens.medium.com/… , basically mount your .npmrc inside your container "source=${localEnv:HOME}${localEnv:USERPROFILE}/.npmrc,target=/home/node/.npmrc,type=bind,consistency=cached" (Same can be done with the other ones)Speculator
Thanks @Speculator I saw this medium article, but it's not helpful when working from a dumb device like an android tablet/iPad. I'm looking for a solution in this scenario.Laccolith
L
1

One option is to use the devcontainer.json secrets key that can use organisation, repository or user defined values:

"secrets": {
  "NAME_OF_SECRET_1": {
    "description": "This is the description of the secret.",
    "documentationUrl": "https://example.com/link/to/info"
  },
  "NAME_OF_SECRET_2": { }
}

See documentation for these features:

Specifying recommended secrets for a repository

Specifying recommended secrets in the dev container configuration

Managing development environment secrets for your repository or organization

Adding a dev container configuration to your repository

Laccolith answered 17/7 at 8:31 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.