Skip to content

feat : Initial support for converting devcontainer.json to devfile.yaml #184

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

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

rohanKanojia
Copy link

What does this PR do?

This PR provides initial implementation for converting devcontainer.json to devfile.yaml. It adds a new file called dev-containers-to-devfile-adapter.ts that is responsible for converting a devcontainer.json into a devfile.yaml

  • Add a new argument devContainerJsonContent to method generateDevfileContext
  • If the abovementioned argument is set, devContainerJsonContent is parsed into an object and dev-container-to-devfile-adapter is invoked to perform the conversion.

DevContainers Specification

https://containers.dev/implementors/json_reference/

Devfile Specification

https://devfile.io/docs/2.3.0/devfile-schema

At the moment, these fields are being considered for conversion:

  • Name -> metadata.name
  • forwardPorts -> components[*].container.endpoints
  • containerEnv -> components[*].container.env
  • remoteEnv -> components[*].container.env
  • overrideCommand -> a command is added to the container while true; do sleep 1000; done
  • Mounts -> components[*].volume
  • Image -> components[*].container.image
  • Build.dockerfile -> components[*].image.dockerfile.uri
  • Build.context -> components[*].image.dockerfile.buildContext
  • Build.args -> components[*].image.dockerfile.args
  • workspaceFolder -> components[*].container.sourceMapping
  • initializeCommand -> events.preStart
  • onCreateCommand -> events.postStart
  • updateContentCommand -> events.postStart
  • postCreateCommand -> events.postStart
  • postStartCommand -> events.postStart
  • postAttachCommand -> events.postStart
  • hostRequirements.cpus -> components[*].container.cpuRequest
  • hostRequirements.memory -> components[*].container.memoryRequest

I couldn't find mapping for these fields:

  • portsAttributes
  • otherPortsAttributes
  • remoteUser
  • containerUser
  • updateRemoteUserUID
  • userEnvProbe
  • shutdownAction
  • Init
  • Privileged
  • capAdd
  • securityOpt
  • Features
  • overrideFeatureInstallOrder
  • Customizations
  • Build.options
  • Build.target
  • build.cacheFrom
  • appPort (legacy equivalent to forwardPorts)
  • workspaceMount
  • runArgs
  • dockerComposeFile
  • Service
  • runServices
  • waitFor
  • hostRequirements.storage
  • hostRequirements.gpu

What issues does this PR fix or reference?

Related to https://issues.redhat.com/browse/CRW-7180

Is it tested? How?

  • I've tested it mainly via unit tests
  • I've also tested it by creating a test project that used development version of this library.

Copy link

openshift-ci bot commented Jun 10, 2025

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: rohanKanojia

The full list of commands accepted by this bot can be found here.

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@rohanKanojia rohanKanojia force-pushed the pr/devcontainers-json-conversion branch 3 times, most recently from 2e69ba2 to bb9bbf5 Compare June 10, 2025 08:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant