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 :
Investigate:
2. Converting devcontainers.json to devfile.yaml on the fly during CDE startup
- If there are both
devfile.yaml & devcontainers.json files in the repo, devfile.yaml should be used for CDE startup (devcontainers.json is ignored in this case)
- if there is only
devcontainers.json during the workspace startup flow, we will try to convert devcontainers.json to devfile.yaml on 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
Motivation
The devcontainer.json file is a configuration file used in Visual Studio Code to define and set up a development container. Both
devcontainer.jsonanddevfile.yamlare 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.jsonshould be natively supported by Eclipse Che. Alternatively, it should be possible to implement some translation layer, e.g., allowing to define adevcontainer.jsonin a project that will be automatically translated it to adevfile.yamlby Eclipse Che under the hood. At this point there isn't a direct, one-to-one automated converter that perfectly translates every nuance of adevcontainer.jsoninto adevfile.yaml(or vice-versa) with full fidelity, it is possible to manually translate or largely reconstruct adevcontainer.jsonconfiguration into adevfile.yaml.Implementation Details
1. Native support of
devcontainers.jsonuse Nested Containers for supporting
devcontainers.jsonon OpenShift:Caveats:
Investigate:
- [ ] https://registry.coder.com/templates/coder/kubernetes-devcontainer
- [ ] Deprecated ? State of Kaniko: Unmaintained? GoogleContainerTools/kaniko#3348
2. Converting
devcontainers.jsontodevfile.yamlon the fly during CDE startupdevfile.yaml&devcontainers.jsonfiles in the repo,devfile.yamlshould be used for CDE startup (devcontainers.jsonis ignored in this case)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