spec icon indicating copy to clipboard operation
spec copied to clipboard

What is the difference between `onCreateCommand`, `updateContentCommand ` and `postCreateCommand`?

Open huweiATgithub opened this issue 1 year ago • 3 comments

From https://containers.dev/implementors/json_reference/#lifecycle-scripts:

all these commands will be executed after the container is created and before it is started. What is the difference between them other than their order of execution? Especially, from the documentation, I don't quite understand:

  • updateContentCommand:

    This command is the second of three that finalizes container setup when a dev container is created. It executes inside the container after onCreateCommand whenever new content is available in the source tree during the creation process.

What does the new content is available in the source tree refer to?

Besides, my understanding is that the difference between onCreateCommand and postCreateCommand is that postCreateCommand can take advantages of user-specific configs and secrets. Will the secrets set for GitHub codespaces only available after postCreateCommand? (to my experience, it is already there on updateContentCommand)

huweiATgithub avatar Jul 17 '24 12:07 huweiATgithub

Subscrige me thanks!

301166 avatar Jul 17 '24 12:07 301166

No dont subcrige

301166 avatar Jul 17 '24 12:07 301166

Hey there! You're correct that the primary differentiator between postCreateCommand and the other two are that postCreateCommand always has access to user specific secrets (so secrets that wouldn't be available in a Codespaces Prebuild, for example). If updateContentCommand is run in the context of a Codespaces Prebuild, it will not have access to the user secrets.

If you're looking for a more visual example, i'd suggest checking out this quick repo that I often use to validate lifecycle hook behavior: https://github.com/joshspicer/lifecycle_hooks

In this example, you can see what secrets the codespace had access to when the prebuild template was created. (Note that if you create, you'll see something slightly different as you won't have access to my prebuild!

Image

Hope this explanation and visual example help with some understanding! We have more info specific to GitHub Codespaces documented here and on specifically prebuilds here.

joshspicer avatar Jul 17 '24 16:07 joshspicer

Thanks all for the discussion here! I'll close out this issue for now, but if there are any follow ups, please just let us know.

bamurtaugh avatar Jul 24 '24 18:07 bamurtaugh