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

Create dev environment with docker #15111

Merged
merged 5 commits into from Sep 30, 2023
Merged

Conversation

trungleduc
Copy link
Member

@trungleduc trungleduc commented Sep 12, 2023

References

Similar to the gitpod setup, but for people who prefer to work offline.
To start a JupyterLab dev container on a UNIX system with docker installed:

bash docker/start.sh

This command will build the docker image if it does not exist, then start the container with JupyterLab running in watch mode. The port 8888 is exposed and the current JupyterLab repo is mounted into the container.

Other available commands:

  • bash docker/start.sh dev: same as calling bash docker/start.sh
  • bash docker/start.sh stop: stop the running container
  • bash docker/start.sh clean: remove the docker image
  • bash docker/start.sh build: rebuild the docker image
  • bash docker/start.sh shell: log into the container's shell with the JupyterLab environment activated. It's useful to run the tests or install dependencies.

How it works

To avoid polluting the node_module directory with packages coming from the host machine while still preserving the hot-reload capability, the js dependencies in the container are actually stored in the /home/$DEV_USER/jupyterlab_cache/node_modules/ while the working directory is mounted to /home/$DEV_USER/jupyterlab. On container startup, the node_modules at jupyterlab_cache is rsync-ed back to the host.

Since the image and container name contain the hash of the current JupyterLab directory, two clones of JupyterLab will generate different images.

How to add dependencies

Due to the above setup, the easiest way to add new dependencies is to log into the container's shell, install the dependencies to update the package.json and yarn.lock files, and then rebuild the docker image.

bash docker/start.sh shell
# In the container shell
jlpm add ...
exit
# back to host shell
bash docker/start.sh build

@jupyterlab-probot
Copy link

Thanks for making a pull request to jupyterlab!
To try out this branch on binder, follow this link: Binder

@trungleduc trungleduc changed the title Create dev. environment with docker Create dev environment with docker Sep 12, 2023
@trungleduc trungleduc force-pushed the docker-dev branch 2 times, most recently from 1ed99e9 to 671a300 Compare September 12, 2023 21:53
@trungleduc trungleduc closed this Sep 12, 2023
@trungleduc trungleduc reopened this Sep 12, 2023
@trungleduc trungleduc marked this pull request as ready for review September 12, 2023 22:23
@trungleduc
Copy link
Member Author

cc @jtpio for awareness

@jtpio
Copy link
Member

jtpio commented Sep 13, 2023

Thanks @trungleduc.

Maybe this will also be useful to enable better support for dev containers and GitHub Codespaces. And also streamline the setup between Gitpod and Codespaces: #13049

@jtpio
Copy link
Member

jtpio commented Sep 13, 2023

Also should there be a new section in the contributing guide to mention how to use this setup? https://jupyterlab.readthedocs.io/en/latest/developer/contributing.html

@trungleduc
Copy link
Member Author

Also should there be a new section in the contributing guide to mention how to use this setup? https://jupyterlab.readthedocs.io/en/latest/developer/contributing.html

Done

@jtpio
Copy link
Member

jtpio commented Sep 18, 2023

Similar to the discussion about Vagrant (#12806 and jupyterlab/frontends-team-compass#152 (comment)), one of the main challenges with this setup will be for maintainers to be able to maintain this Docker configuration, since Docker is yet another tool and not everyone might be familiar with it.

But since Docker is available on GitHub Actions by default maybe there could be a way to put it under tests? To make sure the config does not lag behind or become out of date.

@trungleduc
Copy link
Member Author

trungleduc commented Sep 26, 2023

@jtpio I added a workflow for building and starting the dev container (https://github.com/jupyterlab/jupyterlab/actions/runs/6312097376/job/17137422797?pr=15111). But I am not sure about the activation rate, running this test on every commit wastes a lot of resources.

@krassowski
Copy link
Member

We could run it on PR approval only, as we do with benchmarks.

@jtpio
Copy link
Member

jtpio commented Sep 28, 2023

Otherwise as a cron job?

But I guess we would first need to know if someone from the JupyterLab maintainers will be willing to maintain this new dev setup.

@trungleduc
Copy link
Member Author

Otherwise as a cron job?

But I guess we would first need to know if someone from the JupyterLab maintainers will be willing to maintain this new dev setup.

I can maintain this script but I am also open to move it outside of the JupyterLab repo

@krassowski
Copy link
Member

I am ok with having this in if it helps at least one contributor - if it falls unmaintained, removing it will be easy (4 files to delete plus documentation fragment to cut).

Copy link
Member

@fcollonval fcollonval left a comment

Choose a reason for hiding this comment

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

Thanks @trungleduc

@trungleduc
Copy link
Member Author

Otherwise as a cron job?

But I guess we would first need to know if someone from the JupyterLab maintainers will be willing to maintain this new dev setup.

a cron job sounds good! I'll update the action script.

@krassowski krassowski added this to the 4.1.0 milestone Sep 30, 2023
Copy link
Member

@krassowski krassowski left a comment

Choose a reason for hiding this comment

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

Thanks!

@krassowski krassowski merged commit 0be4a12 into jupyterlab:main Sep 30, 2023
76 of 78 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants