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

Dev containers support for VS Code and GitHub Codespaces #970

Draft
wants to merge 6 commits into
base: 6.1
Choose a base branch
from

Conversation

davisagli
Copy link
Member

Proof of concept.

To do:

  • docs

@davisagli davisagli requested a review from xiru November 30, 2024 20:11
@davisagli davisagli changed the title Dev container Dev containers support for VS Code and GitHub Codespaces Nov 30, 2024
Copy link
Member

@xiru xiru left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

if CODESPACE_NAME:
DOMAIN = os.environ["GITHUB_CODESPACES_PORT_FORWARDING_DOMAIN"]
hostname = f"{CODESPACE_NAME}-8080.{DOMAIN}"
app.virtual_hosting.set_map(f"localhost:8080/VirtualHostBase/https/{hostname}:443/VirtualHostRoot")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is app a global variable?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@xiru Yes, for scripts run with zope's zconsole run command. I'll probably clean this up a bit...just a proof of concept so far

@ramiroluz
Copy link
Member

I am testing it and the build process took me several minutes (in the first run). Looks too slow for using in a training with slow internet connection.

@ramiroluz
Copy link
Member

I did clone the repo.
I checked out the wrong branch devcontainer, then it failed.
I checked out the branch davisagli-devcontainers and it failed again.

'''
Can not execute action!
Traceback (most recent call last):
File "/workspaces/buildout.coredev/.venv/lib/python3.12/site-packages/mxdev/vcs/common.py", line 328, in worker
output = action(**kwargs)
^^^^^^^^^^^^^^^^
File "/workspaces/buildout.coredev/.venv/lib/python3.12/site-packages/mxdev/vcs/git.py", line 289, in checkout
return self.update(**kwargs)
^^^^^^^^^^^^^^^^^^^^^
File "/workspaces/buildout.coredev/.venv/lib/python3.12/site-packages/mxdev/vcs/git.py", line 333, in update
if not self.matches():
^^^^^^^^^^^^^^
File "/workspaces/buildout.coredev/.venv/lib/python3.12/site-packages/mxdev/vcs/git.py", line 328, in matches
raise GitError(f"git remote of '{name}' failed.\n{stderr}")
mxdev.vcs.git.GitError: git remote of 'Plone' failed.
fatal: detected dubious ownership in repository at '/workspaces/buildout.coredev/src/Plone'
To add an exception for this directory, call:

    git config --global --add safe.directory /workspaces/buildout.coredev/src/Plone

Can not execute action!
Traceback (most recent call last):
File "/workspaces/buildout.coredev/.venv/lib/python3.12/site-packages/mxdev/vcs/common.py", line 328, in worker
output = action(**kwargs)
^^^^^^^^^^^^^^^^
File "/workspaces/buildout.coredev/.venv/lib/python3.12/site-packages/mxdev/vcs/git.py", line 289, in checkout
return self.update(**kwargs)
^^^^^^^^^^^^^^^^^^^^^
File "/workspaces/buildout.coredev/.venv/lib/python3.12/site-packages/mxdev/vcs/git.py", line 333, in update
if not self.matches():
^^^^^^^^^^^^^^
File "/workspaces/buildout.coredev/.venv/lib/python3.12/site-packages/mxdev/vcs/git.py", line 328, in matches
raise GitError(f"git remote of '{name}' failed.\n{stderr}")
mxdev.vcs.git.GitError: git remote of 'Products.CMFPlone' failed.
fatal: detected dubious ownership in repository at '/workspaces/buildout.coredev/src/Products.CMFPlone'
To add an exception for this directory, call:

    git config --global --add safe.directory /workspaces/buildout.coredev/src/Products.CMFPlone

Can not execute action!
Traceback (most recent call last):
File "/workspaces/buildout.coredev/.venv/lib/python3.12/site-packages/mxdev/vcs/common.py", line 328, in worker
output = action(**kwargs)
^^^^^^^^^^^^^^^^
File "/workspaces/buildout.coredev/.venv/lib/python3.12/site-packages/mxdev/vcs/git.py", line 289, in checkout
return self.update(**kwargs)
^^^^^^^^^^^^^^^^^^^^^
File "/workspaces/buildout.coredev/.venv/lib/python3.12/site-packages/mxdev/vcs/git.py", line 333, in update
if not self.matches():
^^^^^^^^^^^^^^
File "/workspaces/buildout.coredev/.venv/lib/python3.12/site-packages/mxdev/vcs/git.py", line 328, in matches
raise GitError(f"git remote of '{name}' failed.\n{stderr}")
mxdev.vcs.git.GitError: git remote of 'mockup' failed.
fatal: detected dubious ownership in repository at '/workspaces/buildout.coredev/src/mockup'
To add an exception for this directory, call:

    git config --global --add safe.directory /workspaces/buildout.coredev/src/mockup

Cloned 'docs' with git using branch '6.0' from 'https://github.com/plone/documentation.git'.
Initialized 'docs' submodule at 'submodules/plone.api' with git.
Initialized 'docs' submodule at 'submodules/plone.restapi' with git.
Initialized 'docs' submodule at 'submodules/volto' with git.
There have been errors, see messages above.
make: *** [Makefile:247: .mxmake/sentinels/sources.sentinel] Error 1
[417095 ms] postCreateCommand failed with exit code 2. Skipping any further user-provided commands.
'''

@davisagli
Copy link
Member Author

@ramiroluz Thanks for testing it.

I am testing it and the build process took me several minutes (in the first run). Looks too slow for using in a training with slow internet connection.

This is a scenario where it might make more sense to use the dev container in a GitHub Codespace. Then most of the network transfer is to the remote VM that runs the software, rather than to your own device.

The "fatal: detected dubious ownership" error might happen if you already had some repositories cloned in the src folder before you started the dev container (because the owner outside the container is different than the user inside the container). I'll check how we can avoid this error.

@ramiroluz
Copy link
Member

So I tried on code space and there was one problem:
Captura de tela de 2024-12-01 15-46-02

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.

3 participants