loft-sh / devpod

Codespaces but open-source, client-only and unopinionated: Works with any IDE and lets you use any cloud, kubernetes or just localhost docker.
https://devpod.sh
Mozilla Public License 2.0
8.75k stars 328 forks source link

Support using config files from user machine for container init when using remote setups #996

Open QAston opened 5 months ago

QAston commented 5 months ago

Is your feature request related to a problem?

It'd be great to be able to run some code that uploads configuration files from the host to the devpod. This works with local docker devpod runs, initializeCommand can copy the files to dockerfile context and the data can then be uploaded via dockerfile. Sadly, this doesn't work for remote environments because initializeCommand and docker build are all run remotely, not on the machine with devpod cli and configuration files.

Which solution do you suggest?

Build and run docker images on the machine with devpod-cli or add a separate hook that allows uploading files from the host to the remote for this purpose. Similar to how some user files are already propagated (docker, ssh), but customizable.

Alternatively add some other type of custom hook that runs on the machine with devpod cli, so we can ssh/scp the files ourselves.

Which alternative solutions exist?

pascalbreuninger commented 5 months ago

Hi @QAston, sounds like a good addition. We've discussed adding an --additional-files flag to devpod up which would

  1. Stream these files to the remote machine
  2. Mount them into the devcontainer
  3. Expose them to lifecycle commands

This would also solve your problem, right?

QAston commented 5 months ago

In case we want to be able to run some logic as well to select/prepare files, so I'd personally prefer a custom hook in the config file, similar to the existing hooks but guaranteed to be run on the devpod cli machine. Just having a flag that has to be manually added doesn't provide much over our current approach of wrapping the cli and scp in the wrapper script.

pascalbreuninger commented 5 months ago

fair enough. Be aware that if you rely on the customization to spin up your environment correctly you'd loose the ability to create workspace with other supporting tools and you'd expect everybody to have these files on their machines outside of your git repository. This basically creates a loop where you'd now have to standardize the environment again

QAston commented 5 months ago

In our case this is for optimistically forwarding configuration like git user.name user.email and similar. People have ability to customize and add more options by making a branch of the repository with the devpod config. If the current host-init (initializeCommand) step is not a threat to standardizing the enrionment, a devpod specific step shouldn't be a bigger problem.

Essentially, devpods already do this for docker and ssh-agent and git crednetial helper, it'd be nice to have something that covers custom systems.

euven commented 5 months ago

Hi @QAston, sounds like a good addition. We've discussed adding an --additional-files flag to devpod up which would

1. Stream these files to the remote machine

2. Mount them into the devcontainer

3. Expose them to lifecycle commands

This would also solve your problem, right?

This would solve our problem! :)