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

Persist state and local keys across devcontainer rebuilds in VSCode #40

Open
maxlyth opened this issue Jul 26, 2024 · 0 comments
Open

Comments

@maxlyth
Copy link

maxlyth commented Jul 26, 2024

This devcontainer feature stores the Tailscale state in /workspaces/.tailscale/ but that is outside the structure that is automatically mapped by VSCode to the local project directory so the state was lost each time the container is rebuilt.

I have a few other states that I need to persist across container rebuilds such as shell history and authkeys for CLI tools such as Supabase and Doppler. My solution is to bind mount these to a .devcontainer/volumes/ folder.

You can also use Docker Volumes but these are opaque, easy to loose, and I prefer to keep all config relating to a project together. You probably want to add the volumes directory to .gitignore as there are likely privileged keys stored in there and each project contributor keeps their own separate keys.

To setup, once Tailscale is connected, inside the devcontainer run:
mkdir .devcontainer/volumes && sudo cp -r /workspaces/.tailscale .devcontainer/volumes

and then add the following to the mounts section of devcontainer.json
"source=${localWorkspaceFolder}/.devcontainer/volumes/.tailscale,target=/workspaces/.tailscale,type=bind"

If someone knows a better way to do this then please chime in.

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

1 participant