Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@
// README at: https://github.com/devcontainers/templates/tree/main/src/python
{
"name": "OpenSAFELY",
"image": "ghcr.io/opensafely-core/research-template:v0",
"image": "mcr.microsoft.com/devcontainers/base:ubuntu-22.04",
// Features to add to the dev container. More info: https://containers.dev/features.
"features": {
"ghcr.io/devcontainers/features/docker-in-docker:2": {}
},
"postCreateCommand": "/bin/bash /opt/devcontainer/postCreate.sh ${containerWorkspaceFolder}",
"postAttachCommand": "/bin/bash /opt/devcontainer/postAttach.sh",
"postCreateCommand": "/bin/bash .devcontainer/postCreate.sh",
"postAttachCommand": "/bin/bash .devcontainer/postAttach.sh",
"forwardPorts": [
8787
],
Expand Down Expand Up @@ -40,8 +40,8 @@
"files.autoSave": "afterDelay",
"files.autoSaveDelay": 1000,
"git.autofetch": true,
"python.analysis.extraPaths": [".devcontainer/ehrql-main/"],
"python.defaultInterpreterPath": "/opt/venv/bin/python",
"python.analysis.extraPaths": [".ehrql/"],
"python.defaultInterpreterPath": "./venv/bin/python",
"python.terminal.activateEnvInCurrentTerminal": true,
"python.terminal.activateEnvironment": true,
"window.autoDetectColorScheme": true
Expand Down
1 change: 1 addition & 0 deletions .devcontainer/postAttach.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
opensafely launch rstudio -p 8787 &
26 changes: 26 additions & 0 deletions .devcontainer/postCreate.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# install python and dependencies, set up virtualenv
sudo apt update
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
pip install virtualenv opensafely
python3 -m virtualenv .venv
rm -rf .venv/lib
docker container create --name python-v2 ghcr.io/opensafely-core/python:v2
docker cp python-v2:/opt/venv/lib .venv/
docker rm python-v2

# install R and dependencies
echo "deb https://cloud.r-project.org/bin/linux/ubuntu jammy-cran40/" | sudo tee /etc/apt/sources.list.d/cran.list >/dev/null
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
sudo apt update
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
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
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
docker create --name r-v2 --rm ghcr.io/opensafely-core/r:v2
sudo docker cp r-v2:/usr/local/lib/R/site-library /usr/local/lib/R/
sudo chown -R vscode:vscode /usr/local/lib/R/site-library/


#download and extract latest ehrql source
wget https://github.com/opensafely-core/ehrql/archive/main.zip -P .devcontainer
unzip -o .devcontainer/main.zip -d .devcontainer/
rm .devcontainer/main.zip
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,4 @@ venv/
.Rhistory
.Rproj.user/
.devcontainer/ehrql-main/
.ehrql