|
| 1 | +- Start Date: (fill me in with today's date, YYYY-MM-DD) |
| 2 | +- Status: (One of Proposed, Accepted or Rejected) |
| 3 | + |
| 4 | +# Use devcontainer spec for Renku projects |
| 5 | + |
| 6 | +## Summary |
| 7 | + |
| 8 | +The [development container](https://containers.dev) concept grew out of a need for easily encapsulating |
| 9 | +runtime environments for developing software projects. It has now been turned into a spec with an ecosystem |
| 10 | +of tools growing around it; a project using a devcontainer definition can get a docker container provisioned |
| 11 | +locally by VSCode, remotely by codespaces, or even more remotely in any cloud using [devpod](https://devpod.sh). |
| 12 | +Devcontainers envision composing a runtime environment flexibly from basic components, minimizing the burden |
| 13 | +on the user/developer who just wants to get work done and doesn't want to worry about writing Dockerfiles or figuring |
| 14 | +out how to install the latest cuda libraries. |
| 15 | + |
| 16 | +The proposal here is to use the devcontainer concept for Renku projects. |
| 17 | + |
| 18 | +## Problem Statement |
| 19 | + |
| 20 | +Renku projects are currently bootstrapped via a template which creates a number of files that define the runtime |
| 21 | +for that project, e.g. the `Dockerfile` and depending on the languages used, some other supporting enviroment files. |
| 22 | +In order to be able to run images for Renku projects on the hosted infrastructure, we provide some base images that |
| 23 | +we know will work when used on e.g. renkulab.io. This has a number of issues: |
| 24 | + |
| 25 | +1. if users wants to modify just about anything other than installing python packages, they have to know how to write a Dockerfile (not easy) |
| 26 | +2. we need to maintain a library of docker images for a variety of project dependencies and scenarios (a huge pita) |
| 27 | +3. enabling new functionality is very difficult because it requires developing new docker images or adding things to existing ones |
| 28 | + |
| 29 | +## Key Assumptions |
| 30 | + |
| 31 | +We assume that we want to continue working in containers... |
| 32 | + |
| 33 | +## Possible Solutions |
| 34 | + |
| 35 | +Change nothing, it works! |
| 36 | + |
| 37 | +## Proposed solution |
| 38 | + |
| 39 | +* Create a devcontainer renku feature (see [here](https://github.com/rokroskar/renku-devcontainer-feature/)) |
| 40 | +* Use `devcontainer.json` in renku projects (see [here](https://dev.renku.ch/projects/rokroskar/devcontainer-test)) |
| 41 | + |
| 42 | +The end-result from the user's perspective is that there is no more Dockerfile; the only configuration left is something like this: |
| 43 | + |
| 44 | +```yaml |
| 45 | +{ |
| 46 | + "name": "Python 3.10", |
| 47 | + "build": { |
| 48 | + "context": "..", |
| 49 | + "dockerfile": "../Dockerfile" |
| 50 | + }, |
| 51 | + "features": { |
| 52 | + "ghcr.io/rokroskar/renku-devcontainer-feature/renku:1": {}, |
| 53 | + }, |
| 54 | + "forwardPorts": [8888], |
| 55 | + "remoteUser": "jovyan" |
| 56 | +} |
| 57 | + |
| 58 | +``` |
| 59 | + |
| 60 | +(Ok there is a `Dockerfile` but it contains only a `FROM` line and nothing else). |
| 61 | + |
| 62 | +If I now, for example, wanted to add cuda to this project, all I need to do is add the feature: |
| 63 | + |
| 64 | +```yaml |
| 65 | +{ |
| 66 | + "name": "Python 3.10", |
| 67 | + "build": { |
| 68 | + "context": "..", |
| 69 | + "dockerfile": "../Dockerfile" |
| 70 | + }, |
| 71 | + "features": { |
| 72 | + "ghcr.io/rokroskar/renku-devcontainer-feature/renku:1": {}, |
| 73 | + "ghcr.io/devcontainers/features/nvidia-cuda:1": {} |
| 74 | + }, |
| 75 | + "forwardPorts": [8888], |
| 76 | + "remoteUser": "jovyan" |
| 77 | +} |
| 78 | + |
| 79 | +``` |
| 80 | + |
| 81 | +The gitlab-ci looks like this: |
| 82 | + |
| 83 | +```yaml |
| 84 | +... |
| 85 | + script: | |
| 86 | + CI_COMMIT_SHA_7=$(echo $CI_COMMIT_SHA | cut -c1-7) |
| 87 | + devcontainer build --workspace-folder . --push true --image-name ${CI_REGISTRY_IMAGE}:${CI_COMMIT_SHA_7} |
| 88 | +``` |
| 89 | +
|
| 90 | +The user can now launch this project on any RenkuLab instance as before, _and_ in their local VSCode they can spin it up with the built-in devcontainer tooling. |
| 91 | +This means that we essentially no longer have to worry about local sessions. |
| 92 | +
|
| 93 | +The extra bonus is that with a tool like `devpod`, users can launch their projects on any other cloud, with no changes required to the project itself. |
| 94 | + |
| 95 | +An additional benefit is that we can have some control over which versions of the Renku CLI are installed by controlling the release of the renku feature rather than |
| 96 | +having to modify/update users' projects. |
| 97 | + |
| 98 | +If we decide to use devcontainers for projects, we can think about deeper changes for using this ecosystem, e.g. replacing parts of the notebook service / amalthea or |
| 99 | +at least making them devcontainer-aware. |
| 100 | + |
| 101 | +## Drawbacks |
| 102 | + |
| 103 | +One drawback is that this cannot only be done in templates but will require changes to the UI as well so the blast radius of this change isn't very small. |
| 104 | + |
| 105 | +Another problem is that until we have some deeper support for the spec in our services, some features of the devcontainer will not be used, notably the lifecycle hooks. |
| 106 | + |
| 107 | +## Rationale and Alternatives |
| 108 | + |
| 109 | +This would make Renku projects much more portable and interoperable while at the same time allowing us to _completely stop supporting an entire library of docker images_. |
| 110 | + |
| 111 | +## Unresolved questions |
| 112 | + |
| 113 | +* What to do about data sources / mounts? We currently do some custom things for data source management and it's not obvious how that can translate into this context. |
0 commit comments