-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Description
Motivation
The devcontainer.json file is a configuration file used in Visual Studio Code to define and set up a development container. Both devcontainer.json and devfile.yaml are specifications for defining consistent and reproducible development environments within containers. While they share the common goal of "Infrastructure as Code" for developer setups, they have key differences in their origin, scope, and primary use cases.
Ideally, devcontainer.json should be natively supported by Eclipse Che. Alternatively, it should be possible to implement some translation layer, e.g., allowing to define a devcontainer.json in a project that will be automatically translated it to a devfile.yaml by Eclipse Che under the hood. At this point there isn't a direct, one-to-one automated converter that perfectly translates every nuance of a devcontainer.json into a devfile.yaml (or vice-versa) with full fidelity, it is possible to manually translate or largely reconstruct a devcontainer.json configuration into a devfile.yaml.
Implementation Details
1. Native support of devcontainers.json
use Nested Containers for supporting devcontainers.json on OpenShift:
Caveats:
- Extensions are only available for local VS Code :
- Dev Containers extension https://marketplace.visualstudio.com/items?itemName=ms-vscode-remote.remote-containers
- Remote Development extension https://marketplace.visualstudio.com/search?term=Dev%20Containers&target=VSCode&category=All%20categories&sortBy=Relevance
Investigate:
- Envbuilder https://github.com/coder/envbuilder
- [ ] Deprecated ? State of Kaniko: Unmaintained? GoogleContainerTools/kaniko#3348 - Theia dev-container https://www.npmjs.com/package/@theia/dev-container
2. Converting devcontainers.json to devfile.yaml on the fly during CDE startup
- If there are both
devfile.yaml&devcontainers.jsonfiles in the repo,devfile.yamlshould be used for CDE startup (devcontainers.jsonis ignored in this case) - if there is only
devcontainers.jsonduring the workspace startup flow, we will try to convertdevcontainers.jsontodevfile.yamlon the fly:
General Devcontainer.Json properties and their support
✅ : Converted to devfile.yaml
✘ : Not converted to devfile.yaml
Name ✅
forwardPorts ✅
portsAttributes ✘ (no direct equivalent in devfile)
otherPortsAttributes ✘ (no direct equivalent in devfile)
containerEnv ✅
remoteEnv ✅
remoteUser ✘ (no direct equivalent in devfile)
containerUser ✘ (no direct equivalent in devfile)
updateRemoteUserUID ✘ (related to remoteUser/containerUser)
userEnvProbe ✘ (no direct equivalent in devfile)
overrideCommand ✅
shutdownAction ✘ (no direct equivalent in devfile)
Init ✘ (no direct equivalent in devfile)
Privileged ✘ (no direct equivalent in devfile)
capAdd ✘ (no direct equivalent in devfile)
securityOpt ✘ (no direct equivalent in devfile)
Mounts✅
Features ✘ (no direct equivalent in devfile)
overrideFeatureInstallOrder ✘ (no direct equivalent in devfile)
Customizations ✘ (no direct equivalent in devfile)
Image✅
Build.dockerfile✅
Build.context✅
Build.args✅
Build.options✘ (no direct equivalent in devfile)
Build.target✘ (no direct equivalent in devfile)
build.cacheFrom✘ (no direct equivalent in devfile)
appPort (same as forwardPort but legacy property)
workspaceMount
workspaceFolder✅
runArgs ✘ (no direct equivalent in devfile)
dockerComposeFile ✘ (not supported in devfile)
Service ✘ (related to docker compose, not supported in devfile)
runServices ✘ (related to docker compose, not supported in devfile)
initializeCommand ✅
onCreateCommand ✅
updateContentCommand ✅
postCreateCommand ✅
postStartCommand ✅
postAttachCommand ✅
waitFor ✘ (no direct equivalent in devfile)
hostRequirements.cpus✅
hostRequirements.memory✅
hostRequirements.storage ✘ (no direct equivalent in devfile)
hostRequirements.gpu ✘ (no direct equivalent in devfile)
== Devfile Specification
https://devfile.io/docs/2.3.0/devfile-schema#components-container
== Additional Details
Draft PR for converter approach - devfile/devworkspace-generator#184
Metadata
Metadata
Assignees
Labels
Type
Projects
Status
Status