Skip to content

Unified Devcontainer Configuration for Local and Codespaces Development #527

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

Merged
merged 4 commits into from
Feb 27, 2025

Conversation

pinin4fjords
Copy link
Collaborator

@pinin4fjords pinin4fjords commented Feb 27, 2025

Description:

This pull request updates the devcontainer.json configuration to ensure seamless development across both local VS Code with the Dev Containers extension and GitHub Codespaces. The primary change addresses the handling of the HOST_PROJECT_PATH environment variable, which previously relied on localWorkspaceFolder (specific to local setups).

Changes:

  • remoteEnv.HOST_PROJECT_PATH:
    • Replaced ${localWorkspaceFolder} with /workspaces/training.
    • This change ensures that the HOST_PROJECT_PATH environment variable consistently points to the correct workspace location in both local and Codespaces environments.

Why this works in both environments:

  • Consistent workspaceFolder:
    • The workspaceFolder is maintained as /workspaces/training, providing a consistent starting point for VS Code in both local and cloud setups.
  • Adaptable remoteEnv:
    • In Codespaces, the repository is automatically mounted to /workspaces, making /workspaces/training the correct path.
    • In local devcontainers, the workspaceMount line binds the local folder to /workspaces/training, ensuring that /workspaces/training also points to the local project.
    • Therefore, by setting the HOST_PROJECT_PATH to /workspaces/training, we achieve cross-environment compatibility.
  • Codespaces Automatic Mounting:
    • Codespaces handles the mounting of the repository. Therefore, we do not need to worry about environment specific mounting. The local devcontainer will still use the workspace mount line.
  • Testing:
    • The postCreateCommand line has been added for debugging purposes. It will output "Local Development" or "Codespaces Development" to the terminal, depending on the environment.

This unified configuration streamlines the development process by eliminating the need for environment-specific adjustments, allowing developers to switch seamlessly between local and cloud-based development environments.

Copy link

netlify bot commented Feb 27, 2025

Deploy Preview for nextflow-training ready!

Name Link
🔨 Latest commit c14bf4e
🔍 Latest deploy log https://app.netlify.com/sites/nextflow-training/deploys/67c07e06c7a99100087b689d
😎 Deploy Preview https://deploy-preview-527--nextflow-training.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

@pinin4fjords pinin4fjords changed the title TEST: reintroduce the variable to devcontainer config Unified Devcontainer Configuration for Local and Codespaces Development Feb 27, 2025
@maxulysse
Copy link
Collaborator

I tried it on codespaces and it works.
Sorry that my fix in #500 broke local devcontainer.
But for me the issue is more that codespaces does not follow all the devcontainer guidelines.
Nonetheless, amazing rescue.

Well done 🚀

@adamrtalbot
Copy link
Collaborator

The description is longer than the code changes 👌

@pinin4fjords
Copy link
Collaborator Author

The description is longer than the code changes 👌

AI dun that too

maxulysse
maxulysse previously approved these changes Feb 27, 2025
@maxulysse
Copy link
Collaborator

I tested locally and it works too apparently (not sure if I did it right).

@pinin4fjords
Copy link
Collaborator Author

Thanks @maxulysse @ewels

@pinin4fjords pinin4fjords merged commit cf5f740 into master Feb 27, 2025
8 checks passed
@pinin4fjords pinin4fjords deleted the try_devcontainer_variable_again branch February 27, 2025 15:16
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

Successfully merging this pull request may close these issues.

4 participants