File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 22// README at: https://github.com/devcontainers/templates/tree/main/src/python
33{
44 "name" : " OpenSAFELY" ,
5- "image" : " mcr.microsoft.com/devcontainers/python:3.10 " ,
5+ "image" : " mcr.microsoft.com/devcontainers/base:ubuntu-22.04 " ,
66 // Features to add to the dev container. More info: https://containers.dev/features.
77 "features" : {
88 "ghcr.io/devcontainers/features/docker-in-docker:2" : {}
99 },
10+ "postCreateCommand" : " /bin/bash .devcontainer/postCreate.sh" ,
1011 "postAttachCommand" : " /bin/bash .devcontainer/postAttach.sh" ,
11- "containerEnv" : {"R_LD_LIBRARY_PATH" :" /usr/lib/R-system" },
12+ "forwardPorts" : [
13+ 8787
14+ ],
15+ "portsAttributes" : {
16+ "8787" : {
17+ "label" : " RStudio IDE"
18+ }
19+ },
1220 // Configure tool-specific properties.
1321 "customizations" : {
1422 "codespaces" : {
3341 "files.autoSaveDelay" : 1000 ,
3442 "git.autofetch" : true ,
3543 "python.analysis.extraPaths" : [" .ehrql/" ],
36- "python.defaultInterpreterPath" : " /opt/ venv/bin/python3.10 " ,
44+ "python.defaultInterpreterPath" : " ./ venv/bin/python " ,
3745 "python.terminal.activateEnvInCurrentTerminal" : true ,
3846 "python.terminal.activateEnvironment" : true ,
3947 "window.autoDetectColorScheme" : true
Original file line number Diff line number Diff line change 1- pip install opensafely
2- sudo apt update
3- sudo apt install -y bindfs
4- docker run -it -d --name ehrql --rm ghcr.io/opensafely-core/ehrql:v1 bash
5- mount=$( docker inspect ehrql -f ' {{.GraphDriver.Data.MergedDir}}' )
6- mkdir -p .ehrql
7- sudo mount -o bind " $mount /app/ehrql" .ehrql
8- sudo touch /usr/bin/R
9- sudo mkdir -p /usr/lib/R
10- sudo mkdir -p /usr/lib/R-system
11- sudo mkdir -p /etc/R
12- docker run -it -d --name r-v2 --rm ghcr.io/opensafely-core/r:v2 bash
13- mount=$( docker inspect r-v2 -f ' {{.GraphDriver.Data.MergedDir}}' )
14- sudo mount --bind -o ro " $mount /usr/bin/R" /usr/bin/R
15- sudo bindfs -r --resolve-symlinks " $mount /usr/lib/R" /usr/lib/R
16- sudo bindfs -r --resolve-symlinks " $mount /etc/R" /etc/R
17- sudo bindfs -r --resolve-symlinks " $mount /lib" /usr/lib/R-system
18- docker run -it -d --name python-v2 --rm ghcr.io/opensafely-core/python:v2 bash
19- mount=$( docker inspect python-v2 -f ' {{.GraphDriver.Data.MergedDir}}' )
20- sudo mkdir -p /opt/venv
21- sudo bindfs -r --resolve-symlinks " $mount /opt/venv" /opt/venv
1+ opensafely launch rstudio -p 8787 &
Original file line number Diff line number Diff line change 1+ # install python and dependencies, set up virtualenv
2+ sudo apt update
3+ wget https://github.com/opensafely-core/python-docker/raw/refs/heads/main/v2/dependencies.txt -q -O - | sed ' s/^#.*//' | sudo xargs apt-get install --yes --no-install-recommends
4+ pip install virtualenv opensafely
5+ python3 -m virtualenv .venv
6+ rm -rf .venv/lib
7+ docker container create --name python-v2 ghcr.io/opensafely-core/python:v2
8+ docker cp python-v2:/opt/venv/lib .venv/
9+ docker rm python-v2
10+
11+ # install R and dependencies
12+ echo " deb https://cloud.r-project.org/bin/linux/ubuntu jammy-cran40/" | sudo tee /etc/apt/sources.list.d/cran.list > /dev/null
13+ sudo /usr/lib/apt/apt-helper download-file ' https://cloud.r-project.org/bin/linux/ubuntu/marutter_pubkey.asc' /etc/apt/trusted.gpg.d/cran_ubuntu_key.asc
14+ sudo apt update
15+ wget https://raw.githubusercontent.com/opensafely-core/r-docker/refs/heads/main/v2/dependencies.txt -q -O - | sed ' s/^#.*//' | sudo xargs apt-get install --yes --no-install-recommends
16+ wget https://raw.githubusercontent.com/opensafely-core/r-docker/refs/heads/main/scripts/rprofile-site-append-1.R -q -O - | sudo tee -a /usr/lib/R/etc/Rprofile.site > /dev/null
17+ wget https://raw.githubusercontent.com/opensafely-core/r-docker/refs/heads/main/scripts/rprofile-site-append-2.R -q -O - | sudo tee -a /usr/lib/R/etc/Rprofile.site > /dev/null
18+ docker create --name r-v2 --rm ghcr.io/opensafely-core/r:v2
19+ sudo docker cp r-v2:/usr/local/lib/R/site-library /usr/local/lib/R/
20+ sudo chown -R vscode:vscode /usr/local/lib/R/site-library/
21+
22+
23+ # download and extract latest ehrql source
24+ wget https://github.com/opensafely-core/ehrql/archive/main.zip -P .devcontainer
25+ unzip -o .devcontainer/main.zip -d .devcontainer/
26+ rm .devcontainer/main.zip
You can’t perform that action at this time.
0 commit comments