Skip to content

Commit

Permalink
Merge pull request #68 from opensafely/github-codespaces
Browse files Browse the repository at this point in the history
Add GitHub Codespaces
  • Loading branch information
rose-higgins authored Jun 6, 2024
2 parents 1246d00 + c54401e commit 1985b50
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 44 deletions.
31 changes: 0 additions & 31 deletions .devcontainer/Dockerfile

This file was deleted.

9 changes: 9 additions & 0 deletions .devcontainer/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# Devcontainer Configuration

This folder contains configuration files required for Codespaces/devcontainers.
Please do not modify its contents unless you know what you are doing and there
is a specific change to the devcontainer configuration you need to make.

If you believe you have a broken configuration or are unsure if you have the
latest version of the configuration, please follow the
[instructions to add codespaces to your project](https://docs.opensafely.org/getting-started/how-to/add-github-codespaces-to-your-project/).
34 changes: 24 additions & 10 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,12 @@
// README at: https://github.com/devcontainers/templates/tree/main/src/python
{
"name": "OpenSAFELY",
"image": "ghcr.io/opensafely/research-template:latest",
"image": "ghcr.io/opensafely-core/research-template:v0",
// Features to add to the dev container. More info: https://containers.dev/features.
"features": {
"ghcr.io/devcontainers/features/docker-in-docker:2": {
"moby": true,
"azureDnsAutoDetection": true,
"installDockerBuildx": true,
"version": "latest",
"dockerDashComposeVersion": "v2"
}
"ghcr.io/devcontainers/features/docker-in-docker:2": {}
},
"postCreateCommand": "/bin/bash .devcontainer/postCreate.sh",
"postCreateCommand": "/bin/bash .devcontainer/postCreate.sh ${containerWorkspaceFolder}",
"postAttachCommand": {
"rstudio-start": "sudo rstudio-server start"
},
Expand All @@ -27,12 +21,32 @@
},
// Configure tool-specific properties.
"customizations": {
"codespaces": {
"repositories": {
"opensafely/server-instructions": {
"permissions": {
"contents": "read"
}
}
}
},
"vscode": {
"extensions": [
"ms-python.python",
"ms-toolsai.jupyter",
"ms-toolsai.jupyter-renderers"
]
],
"settings": {
"extensions.ignoreRecommendations": true,
"files.autoSave": "afterDelay",
"files.autoSaveDelay": 1000,
"git.autofetch": true,
"python.analysis.extraPaths": [".devcontainer/ehrql-main/"],
"python.defaultInterpreterPath": "/opt/venv/bin/python",
"python.terminal.activateEnvInCurrentTerminal": true,
"python.terminal.activateEnvironment": true,
"window.autoDetectColorScheme": true
}
}
},
// Uncomment to connect as root instead. More info: https://aka.ms/dev-containers-non-root.
Expand Down
1 change: 1 addition & 0 deletions .devcontainer/gitignore.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
ehrql-main
6 changes: 3 additions & 3 deletions .devcontainer/postCreate.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@

set -euo pipefail

pip3 install --user -r .devcontainer/requirements.in
/usr/local/bin/pip3 install --user -r .devcontainer/requirements.in

#set R working directory
! grep -q `pwd` $R_HOME/etc/Rprofile.site && sudo tee -a $R_HOME/etc/Rprofile.site <<< "setwd(\"`pwd`\")"
! grep -q "$1" $R_HOME/etc/Rprofile.site && sudo tee -a $R_HOME/etc/Rprofile.site <<< "setwd(\"$1\")"
#set RStudio working directory
! grep -q `pwd` ~/.config/rstudio/rstudio-prefs.json && cat ~/.config/rstudio/rstudio-prefs.json | jq ". + {\"initial_working_directory\":\"`pwd`\"}" > ~/.config/rstudio/rstudio-prefs.json
! grep -q "$1" ~/.config/rstudio/rstudio-prefs.json && cat ~/.config/rstudio/rstudio-prefs.json | jq ". + {\"initial_working_directory\":\"$1\"}" > ~/.config/rstudio/rstudio-prefs.json
#download and extract latest ehrql source
wget https://github.com/opensafely-core/ehrql/archive/main.zip -P .devcontainer
Expand Down

0 comments on commit 1985b50

Please sign in to comment.