Skip to content

Commit ae976fe

Browse files
committed
Update devcontainers
- Incorporate non-root user changes from devcontainers-update branch. - Incorporate and fix mixed r/miniforge environment from same branch. - Attempt to fix error when launching github codespaces: "Oh no, it looks like you are offline!" Possibly due to blocked network request, or an outdated extension?
1 parent aa81b0e commit ae976fe

File tree

6 files changed

+78
-168
lines changed

6 files changed

+78
-168
lines changed

.devcontainer/Dockerfile

Lines changed: 30 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,25 @@
1-
# FROM mcr.microsoft.com/devcontainers/miniconda:0-3
2-
FROM quay.io/condaforge/miniforge3:23.3.1-1
1+
FROM quay.io/condaforge/miniforge3:23.11.0-0
2+
3+
# Or your actual UID, GID on Linux if not the default 1000
4+
ARG USERNAME=vscode
5+
ARG USER_UID=1000
6+
ARG USER_GID="${USER_UID}"
37

48
# add conda-forge and bioconda channels to the top of the priority list and enable mamba solver
5-
RUN /opt/conda/bin/conda config --add channels defaults && \
6-
/opt/conda/bin/conda config --add channels bioconda && \
7-
/opt/conda/bin/conda config --add channels conda-forge
8-
# channel priority strict seems to mess up package resolution
9-
# /opt/conda/bin/conda config --set channel_priority strict
9+
RUN /opt/conda/bin/conda config --add channels bioconda \
10+
&& /opt/conda/bin/conda config --add channels conda-forge
11+
# channel priority strict seems to mess up package resolution
12+
# /opt/conda/bin/conda config --set channel_priority strict
1013

1114
# Copy environment.yml (if found) to a temp location so we update the environment. Also
1215
# copy "noop.txt" so the COPY instruction does not fail if no environment.yml exists.
16+
# This updates the base environment instead of creating a new named virtual environment (mamba env create -f env.yml)
1317
COPY environment.yml* .devcontainer/noop.txt /tmp/conda-tmp/
14-
RUN if [ -f "/tmp/conda-tmp/environment.yml" ]; then umask 0002 && /opt/conda/bin/mamba env update -n base -f /tmp/conda-tmp/environment.yml; fi \
18+
RUN if [ -f "/tmp/conda-tmp/environment.yml" ]; then umask 0002 \
19+
&& /opt/conda/bin/mamba env update -n base -f /tmp/conda-tmp/environment.yml; fi \
1520
&& rm -rf /tmp/conda-tmp
1621

17-
# RUN if [ -f "/tmp/conda-tmp/environment.yml" ]; then umask 0002 && /opt/conda/bin/mamba env create -f /tmp/conda-tmp/environment.yml; fi \
18-
# && rm -rf /tmp/conda-tmp
19-
20-
# [Optional] Uncomment to install a different version of Python than the default
21-
# RUN conda install -y python=3.6 \
22-
# && pip install --no-cache-dir pipx \
23-
# && pipx reinstall-all
24-
25-
# [Optional] Uncomment this section to install additional OS packages.
22+
# Install additional packages.
2623
RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \
2724
&& apt-get -y install --no-install-recommends \
2825
nano \
@@ -37,3 +34,19 @@ RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \
3734
htop \
3835
tree \
3936
graphviz
37+
38+
# Create a non-root user - see https://aka.ms/vscode-remote/containers/non-root-user,
39+
# https://github.com/microsoft/vscode-dev-containers/issues/108,
40+
# and https://github.com/mamba-org/micromamba-docker/blob/521003c092aca4be4800220a883ebebf5bacbd6d/Dockerfile#L44
41+
RUN groupadd --gid 1000 "${USERNAME}" \
42+
&& useradd -s /bin/bash --uid "${USER_UID}" --gid "${USER_GID}" -m "${USERNAME}" \
43+
# Add sudo support
44+
&& apt-get install -y sudo \
45+
&& echo "${USERNAME}" ALL=\(root\) NOPASSWD:ALL > "/etc/sudoers.d/${USERNAME}" \
46+
&& chmod 0440 "/etc/sudoers.d/${USERNAME}" \
47+
# Transfer mamba ownership to user
48+
&& chmod -R a+rwx /opt/conda \
49+
# Clean up
50+
&& apt-get autoremove -y \
51+
&& apt-get clean -y \
52+
&& rm -rf /var/lib/apt/lists/*

.devcontainer/devcontainer.json

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
// For format details, see https://aka.ms/devcontainer.json. For config options, see the
22
// README at: https://github.com/devcontainers/templates/tree/main/src/miniconda
33
{
4-
"name": "Bioinformatics training environment",
4+
"name": "Unix tools and (bio)conda (miniforge)",
55
"build": {
66
"context": "..",
77
"dockerfile": "Dockerfile"
88
},
9+
"containerUser": "vscode",
910
// {
1011
// "runArgs": [
1112
// "--log-driver=none"
@@ -48,38 +49,37 @@
4849
"customizations": {
4950
"vscode": {
5051
"settings": {
51-
"workbench.colorTheme": "Sonokai Maia",
5252
"workbench.editor.highlightModifiedTabs": true,
5353
"workbench.tree.renderIndentGuides": "always",
54+
"indentRainbow.lightIndicatorStyleLineWidth": 5,
55+
"indentRainbow.indicatorStyle": "light",
5456
"workbench.editor.wrapTabs": true,
5557
"explorer.compactFolders": false,
5658
"files.eol": "\n",
5759
"editor.wordWrap": "on",
60+
"editor.renderWhitespace": "trailing",
5861
"editor.bracketPairColorization.enabled": true,
59-
"indentRainbow.lightIndicatorStyleLineWidth": 5,
60-
"indentRainbow.indicatorStyle": "light",
6162
// "terminal.integrated.scrollback": 10000,
62-
"editor.renderWhitespace": "trailing",
6363
"files.trimFinalNewlines": true,
6464
"files.trimTrailingWhitespace": true,
6565
"editor.formatOnType": true,
6666
"editor.formatOnSave": true,
6767
},
6868
"extensions": [
6969
// bash extensions
70-
"mads-hartmann.bash-ide-vscode",
7170
"foxundermoon.shell-format",
71+
"mads-hartmann.bash-ide-vscode",
7272
"timonwong.shellcheck",
7373

7474
// QoL
7575
"streetsidesoftware.code-spell-checker",
7676
"oderwat.indent-rainbow",
7777
"mechatroner.rainbow-csv",
7878
"ionutvmi.path-autocomplete",
79-
"fabiospampinato.vscode-diff",
8079

81-
// R
82-
"REditorSupport.r",
80+
// // // R
81+
// // "REditorSupport.r",
82+
// // "REditorSupport.r-syntax",
8383

8484
// general formatting
8585
"esbenp.prettier-vscode",

.devcontainer/mix/Dockerfile

Lines changed: 0 additions & 31 deletions
This file was deleted.

.devcontainer/mix/devcontainer.docker.json

Lines changed: 0 additions & 82 deletions
This file was deleted.

.devcontainer/mix/devcontainer.json

Lines changed: 28 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,44 @@
11
{
2-
"name": "Unix tools, bioconda and RStudio",
2+
"name": "Unix tools, (bio)conda (miniforge) and R(Studio)",
33
// https://rocker-project.org/images/devcontainer/images.html
44
"image": "ghcr.io/rocker-org/devcontainer/tidyverse:4",
5+
// Base image could be modified to allow non-root user to start rstudio server
6+
// See https://github.com/rocker-org/rocker-versioned2/issues/592
7+
// "build": {
8+
// "context": "../..",
9+
// "dockerfile": "Dockerfile"
10+
// },
11+
// "remoteUser": "rstudio",
12+
// but this seems to fail.
13+
// Fortunately, the rocker environments seem to launch
14+
// a regular user bash session: https://github.com/rocker-org/rocker/wiki/managing-users-in-docker
515
"features": {
616
// https://github.com/rocker-org/devcontainer-features/blob/main/src/rstudio-server/README.md
7-
// already pre-installed in tidyverse container - https://rocker-project.org/images/devcontainer/images.html#rstudio-server
17+
// RStudio is already pre-installed in tidyverse container - https://rocker-project.org/images/devcontainer/images.html#rstudio-server
818
"ghcr.io/rocker-org/devcontainer-features/rstudio-server:latest": {},
19+
// https://github.com/rocker-org/devcontainer-features/tree/main/src/apt-packages
20+
"ghcr.io/rocker-org/devcontainer-features/apt-packages:1": {
21+
"packages": "libglpk-dev,nano,vim,less,git,screen,tmux,wget,curl,colordiff,htop,tree,graphviz" // "libglpk-dev" is required for igraph
22+
},
923
// https://github.com/rocker-org/devcontainer-features/blob/main/src/r-packages/README.md
1024
"ghcr.io/rocker-org/devcontainer-features/r-packages:1": {
11-
"packages": "tidyverse,rmarkdown,BiocManager,shiny,shinythemes,markdown",
25+
"packages": "devtools,languageserver,tidyverse,rmarkdown,markdown,shiny,shinythemes,BiocManager,github::bahlolab/isoRelate,sjmisc,networkD3,igraph,RColorBrewer,viridis,vcfR,poppr,ggfortify",
1226
"installSystemRequirements": true
1327
},
1428
// https://github.com/rocker-org/devcontainer-features/blob/main/src/miniforge/README.md
15-
"ghcr.io/rocker-org/devcontainer-features/miniforge:1": {
29+
"ghcr.io/rocker-org/devcontainer-features/miniforge:2": {
1630
"version": "latest",
17-
"variant": "Mambaforge"
31+
"variant": "Miniforge3"
1832
}
1933
// https://github.com/mamba-org/devcontainer-features/tree/main/src/micromamba
2034
// "ghcr.io/mamba-org/devcontainer-features/micromamba:1": {}
2135
},
2236
// Use 'postCreateCommand' to run commands after the container is created.
2337
// "postStartCommand": "if [ -f environment.yml ]; then umask 0002 && /opt/conda/bin/mamba env update -n base -f environment.yml; fi",
24-
"postCreateCommand": "/opt/conda/bin/mamba env update -n base -f environment.yml",
38+
// "postCreateCommand": "/opt/conda/bin/mamba env update -y -n base -f environment.yml",
39+
// Disabled because the postCreateCommand seems to interfer with the internal commands run
40+
// by the rocker image which set the R package repositories, and it becomes impossible
41+
// to use install.packages() afterwards, even when specifying a repository url.
2542
"postAttachCommand": {
2643
"rstudio-start": "rserver"
2744
},
@@ -36,38 +53,37 @@
3653
"customizations": {
3754
"vscode": {
3855
"settings": {
39-
"workbench.colorTheme": "Sonokai Maia",
4056
"workbench.editor.highlightModifiedTabs": true,
4157
"workbench.tree.renderIndentGuides": "always",
58+
"indentRainbow.lightIndicatorStyleLineWidth": 5,
59+
"indentRainbow.indicatorStyle": "light",
4260
"workbench.editor.wrapTabs": true,
4361
"explorer.compactFolders": false,
4462
"files.eol": "\n",
4563
"editor.wordWrap": "on",
64+
"editor.renderWhitespace": "trailing",
4665
"editor.bracketPairColorization.enabled": true,
47-
"indentRainbow.lightIndicatorStyleLineWidth": 5,
48-
"indentRainbow.indicatorStyle": "light",
4966
// "terminal.integrated.scrollback": 10000,
50-
"editor.renderWhitespace": "trailing",
5167
"files.trimFinalNewlines": true,
5268
"files.trimTrailingWhitespace": true,
5369
"editor.formatOnType": true,
5470
"editor.formatOnSave": true,
5571
},
5672
"extensions": [
5773
// bash extensions
58-
"mads-hartmann.bash-ide-vscode",
5974
"foxundermoon.shell-format",
75+
"mads-hartmann.bash-ide-vscode",
6076
"timonwong.shellcheck",
6177

6278
// QoL
6379
"streetsidesoftware.code-spell-checker",
6480
"oderwat.indent-rainbow",
6581
"mechatroner.rainbow-csv",
6682
"ionutvmi.path-autocomplete",
67-
"fabiospampinato.vscode-diff",
6883

6984
// R
7085
"REditorSupport.r",
86+
"REditorSupport.r-syntax",
7187

7288
// general formatting
7389
"esbenp.prettier-vscode",

0 commit comments

Comments
 (0)