Skip to content
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

[question] How can configure a feature to start after the devcontainers is created? #41

Open
eddumelendez opened this issue Mar 15, 2023 · 6 comments

Comments

@eddumelendez
Copy link

The feature I have in mind depends on a secret which is provided when Codespaces is initialized. I have tried using entrypoint, postStartCommand and postAttachCommand without success. I can see the agent is downloaded and can be initialized manually once Codespaces starts but what I'm looking for is to make it start automatically.

@joshspicer
Copy link
Member

joshspicer commented Mar 15, 2023

In the docker-in-docker Feature, we write a script to /usr/local/share in the Feature's install.sh script, and then execute it as the entrypoint (https://github.com/devcontainers/features/blob/main/src/docker-in-docker/devcontainer-feature.json#L49). Would that work?

@eddumelendez
Copy link
Author

eddumelendez commented Mar 15, 2023

I tried like that but without success... probably because I didn't specify any remoteEnv for the token?

@joshspicer
Copy link
Member

joshspicer commented Mar 15, 2023

Ah sorry I missed the 'secret' portion of this. Version 0.32.0+ of the dev container CLI will respect lifecycle hooks in Features.

Over the next day or so, we'll be rolling out this new version of the CLI in codespace. Once it's available (you can see from a codespace creation log the version of @devcontainers/cli), you should be able to use postStartCommand, which will have access to the codespace's user secrets.

I put together a demo here (ignore the entrypoint portions, those were me experimenting):

https://github.com/codspace/codespace_secrets_with_features/blob/5d1acc38262b6b3eea0e330b99e934ab1e62ee71/.devcontainer/features/aaa/devcontainer-feature.json#L6

image

Are you able to refactor your Feature in such a way that you can "start" it in the postStartCommand, when secrets are available to you?

@eddumelendez
Copy link
Author

thanks! Looking forward to it :)

@eddumelendez
Copy link
Author

Hi @joshspicer is this already available?

@eddumelendez
Copy link
Author

I moved it to postStartCommand but no success. I see the token set and the binary downloaded but can not keep the process running. This is my feature https://github.com/eddumelendez/test-devcontainer/blob/main/src/tcc/devcontainer-feature.json

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants