opensafely-core / codespaces-initiative

Improving the use of OpenSAFELY in Codespaces
MIT License
0 stars 0 forks source link

Create improved dev container configuration #43

Closed lucyb closed 4 months ago

lucyb commented 5 months ago

Based on the investigation done in #9.

Our aim is to provide a Codepsaces environment that's ready to go for researchers using Python or RStudio to write code for the OpenSAFELY pipeline.

This configuration will provide a development environment for researchers containing:

We are not expecting to support work done outside of the OpenSAFELY pipeline or analyses done in Stata. We will provide only limited support for older studies, as we're aiming our efforts currently towards newer users.

This configuration will be used to create Codespaces by researchers, so it should be tested out by several researchers before it can be considered complete.

It does not need to particularly fast, but does need to be fast enough to reasonably use. This means we'll need to build a Docker image and upload it to ghcr, rather than build an image on each Codespace start up. ~As part of this ticket, we should consider how we're going to version changes to both the Docker image and the other devcontainer configuration. For example, we could agree to avoid referencing the "latest" tag by default and start with a v1.~ EDIT: we'll do this in ticket x.

We should consider how we'll release this update to the research-template repo to new and existing users. We may want to script the creation of PRs to make it easier, especially as we anticipate further updates. This automation work should also be done in another ticket (see #47).

The majority of the changes to the research template itself are in this PR.

TODO

lucyb commented 5 months ago

As part of testing these changes, I've sent the new configuration to Tom P, Will and Rose. It's worked fine for Tom P and Rose, so far. Still waiting to hear back from Will.

One external user is keen to try it out (thread).

Jongmassey commented 5 months ago

See if DISABLE_AUTH=true sudo rstudio-server start works to remove the login prompt. It's possible that the env var isn't being passed into the dev container though. If it doesn't work, don't try to fix and consider this item done.

This required looking inside the rocker scrips that read that env var and copying its behaviour. You may have to clear cookies for this to work.

Jongmassey commented 5 months ago

Move to rocker base image and copy packages from r action image. Configure renv to use the packages

Following advice from Tom P, I've removed renv from the equation and dropped them in the system library

Jongmassey commented 5 months ago

Rename python venv to make its purpose clearer in case we create additional venvs in future (e.g call it “python:v2” to match the Action image)

Done, needed to change the path in the smoke test accordingly. Used python-v2 rather than python:v2 as colons not allowed in paths.

For some reason the virtualenv isn't activating in my local devcontainer run of this. I'll push an updated image and see if that's the case in codespaces.

Jongmassey commented 5 months ago

Rename python venv to make its purpose clearer in case we create additional venvs in future (e.g call it “python:v2” to match the Action image)

OK so at least some of the problems I've been having are to do with the path to the virtualenv no longer matching what's in the activation script (which is created upon virtualenv creation). I suggest reverting to /opt/venv to match what's in the opensafely python image for now. In future we could either modify the activate script or recreate the venv when the times comes to need to support multiple venvs. Thoughts @lucyb ?

Jongmassey commented 5 months ago

Remove dockerfile as this will be added to a new repo as part of

I've rebased such that there never was a Dockerfile in there in the first place

iaindillingham commented 4 months ago

I think this issue is closed by opensafely/research-template#120.

This configuration will be used to create Codespaces by researchers, so it should be tested out by several researchers before it can be considered complete.

I think the above will be addressed by:

Jongmassey commented 4 months ago

#120 merged