Skip to content

Allow devcontainer.json to be used for defining Cloud Development Environment #23458

@ibuziuk

Description

@ibuziuk

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:

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

Metadata

Metadata

Assignees

Labels

area/dashboardarea/devworkspace-generatorarea/devworkspace-operatorengine/devworkspaceIssues related to Che configured to use the devworkspace controller as workspace engine.kind/epicA long-lived, PM-driven feature request. Must include a checklist of items that must be completed.roadmap/6-monthsEpics that are planned to complete in the medium term (within 6 months)

Type

No type

Projects

Status

No status

Status

Analyzing

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions