cli icon indicating copy to clipboard operation
cli copied to clipboard

Proposal: Add `devcontainers init` command similar to `devcontainerize`

Open mathdroid opened this issue 1 year ago • 3 comments

Hello devcontainers team,

I've recently created a tool called devcontainerize (https://www.npmjs.com/package/devcontainerize, https://github.com/mathdroid/devcontainerize) that automatically detects a project's type and sets up the appropriate devcontainer configuration.

The tool:

  1. Detects the project type based on files in the current directory.
  2. Fetches appropriate Dockerfile and devcontainer.json from the devcontainers/images repository.
  3. Creates a .devcontainer directory with these files.
  4. Optionally adds .devcontainer to .gitignore if in a Git repository.

I believe a similar functionality could be valuable as part of the official devcontainers CLI, potentially as a devcontainers init command.

I'm keen to contribute this functionality to the official CLI if the team is interested. This could help streamline the process of setting up devcontainers for various project types and improve the overall developer experience.

Would you be open to discussing this further? I'd be happy to provide more details about the implementation or discuss how we could adapt it to fit within the existing CLI structure.

mathdroid avatar Sep 09 '24 10:09 mathdroid

Hi there! Thanks so much for opening this issue and for sharing the tool you created - this is super interesting!

I'd love to learn more about how you're thinking of implementing this. A couple thoughts that came to mind:

  • The CLI would need to have access to the index of dev container resources https://containers.dev/collections (it doesn't currently)
  • We'd probably want to implement functionality directly into the CLI, rather than calling upon a separate tool (i.e. avoid potential breakage issues)
  • We might want to put this functionality / command behind an experimental flag, to help measure user expectations (there isn't a guarantee the recommended setup will be 100% ideal)

bamurtaugh avatar Oct 01 '24 16:10 bamurtaugh

I am also very interested in this feature. I would propose to not do anything fancy at this time and just include basic functionality.

  • create .devcontainer dir
  • create .devcontainer/devcontainer.json file
  • maybe prompts for the value of the image field and whether or not the user wants to have their own Dockerfile. If yes create it empty and reference it in the json file.

This of course can evolve over time.

Thoughts @bamurtaugh?

albertocavalcante avatar Mar 15 '25 04:03 albertocavalcante

just read this again, would love to implement the simple version!

Best Regards,

Muhammad Mustadi

On Sat, 15 Mar 2025 at 11.15 Alberto Cavalcante @.***> wrote:

I am also very interested in this feature. I would propose to not do anything fancy add this time and just include basic functionality.

  • create .devcontainer dir
  • create .devcontainer/devcontainer.json file
  • maybe prompts for the value of the image field and whether or not the user wants to have their own Dockerfile. If yes create it empty and reference it in the json file.

This of course can evolve over time.

Thoughts @bamurtaugh https://github.com/bamurtaugh?

— Reply to this email directly, view it on GitHub https://github.com/devcontainers/cli/issues/890#issuecomment-2726196103, or unsubscribe https://github.com/notifications/unsubscribe-auth/AA4TGMUMMTP3JL4NSMS6TUT2UOSMZAVCNFSM6AAAAABN4H4SMSVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDOMRWGE4TMMJQGM . You are receiving this because you authored the thread.Message ID: @.***> [image: albertocavalcante]albertocavalcante left a comment (devcontainers/cli#890) https://github.com/devcontainers/cli/issues/890#issuecomment-2726196103

I am also very interested in this feature. I would propose to not do anything fancy add this time and just include basic functionality.

  • create .devcontainer dir
  • create .devcontainer/devcontainer.json file
  • maybe prompts for the value of the image field and whether or not the user wants to have their own Dockerfile. If yes create it empty and reference it in the json file.

This of course can evolve over time.

Thoughts @bamurtaugh https://github.com/bamurtaugh?

— Reply to this email directly, view it on GitHub https://github.com/devcontainers/cli/issues/890#issuecomment-2726196103, or unsubscribe https://github.com/notifications/unsubscribe-auth/AA4TGMUMMTP3JL4NSMS6TUT2UOSMZAVCNFSM6AAAAABN4H4SMSVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDOMRWGE4TMMJQGM . You are receiving this because you authored the thread.Message ID: @.***>

mathdroid avatar Mar 15 '25 09:03 mathdroid