Skip to content

Commit

Permalink
update devcontainer
Browse files Browse the repository at this point in the history
  • Loading branch information
KrisThielemans committed Nov 3, 2024
1 parent cd8544b commit 08ef5aa
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 27 deletions.
22 changes: 9 additions & 13 deletions .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -29,29 +29,25 @@ ARG USERNAME="vscode"
ARG USER_UID=1000
ARG USER_GID=$USER_UID
ARG CONDA_GID=900
ARG CONDA_ENVIRONMENT_NAME=prd
ARG VSCODE_DEV_CONTAINERS_SCRIPT_LIBRARY_VERSION=v0.229.0
ARG CONDA_ENVIRONMENT_NAME=petsird

RUN apt-get update && apt-get install -y \
libc6-dbg \
&& rm -rf /var/lib/apt/lists/*

# Enable non-root Docker access in container
ARG ENABLE_NONROOT_DOCKER="true"
# Use the OSS Moby CLI instead of the licensed Docker CLI
ARG USE_MOBY="false"
RUN script=$(curl -fsSL "https://raw.githubusercontent.com/microsoft/vscode-dev-containers/${VSCODE_DEV_CONTAINERS_SCRIPT_LIBRARY_VERSION}/script-library/docker-debian.sh") && bash -c "$script" -- "${ENABLE_NONROOT_DOCKER}" "/var/run/docker-host.sock" "/var/run/docker.sock" "${USERNAME}" "${USE_MOBY}"
ARG DOCKER_VERSION="27.0.3"
RUN script=$(curl -fsSL "https://raw.githubusercontent.com/devcontainers/features/2951f0481a488ea43a6f2ea6f18a47f0a0bf744d/src/docker-outside-of-docker/install.sh") \
&& VERSION=${DOCKER_VERSION} DOCKERDASHCOMPOSEVERSION="none" bash -c "$script"

# Setting the ENTRYPOINT to docker-init.sh will configure non-root access to
# the Docker socket if "overrideCommand": false is set in devcontainer.json.
# The script will also execute CMD if you need to alter startup behaviors.
ENTRYPOINT [ "/usr/local/share/docker-init.sh" ]
CMD [ "sleep", "infinity" ]

ARG MAMBAFORGE_VERSION=22.9.0-2

# Based on https://github.com/conda-forge/miniforge-images/blob/master/ubuntu/Dockerfile
RUN wget --no-hsts --quiet https://github.com/conda-forge/miniforge/releases/download/${MAMBAFORGE_VERSION}/Mambaforge-${MAMBAFORGE_VERSION}-Linux-$(uname -m).sh -O /tmp/miniforge.sh \
RUN wget --no-hsts --quiet https://github.com/conda-forge/miniforge/releases/latest/download/Miniforge3-$(uname)-$(uname -m).sh -O /tmp/miniforge.sh \
&& /bin/bash /tmp/miniforge.sh -b -p /opt/conda \
&& rm /tmp/miniforge.sh \
&& /opt/conda/bin/conda clean --tarballs --index-cache --packages --yes \
Expand All @@ -67,8 +63,8 @@ RUN wget --no-hsts --quiet https://github.com/conda-forge/miniforge/releases/dow
# Create a conda environment from the environment file in the repo root.
COPY --from=file-normalizer --chown=$USER_UID:conda /data/environment.yml /tmp/build/
RUN umask 0002 \
&& /opt/conda/bin/mamba env create -f /tmp/build/environment.yml \
&& /opt/conda/bin/mamba clean -fy \
&& /opt/conda/bin/conda env create -f /tmp/build/environment.yml \
&& /opt/conda/bin/conda clean -fy \
&& sudo chown -R :conda /opt/conda/envs

# Add a file that is to be sourced from .bashrc and from the devops pipeline stages
Expand All @@ -87,11 +83,11 @@ ENV CMAKE_GENERATOR=Ninja

# Create a kits file for the VSCode CMake Tools extension, so you are not prompted for which kit to select whenever you open VSCode
RUN mkdir -p /home/vscode/.local/share/CMakeTools \
&& echo '[{"name":"GCC-10","compilers":{"C":"/opt/conda/envs/prd/bin/x86_64-conda_cos6-linux-gnu-gcc","CXX":"/opt/conda/envs/prd/bin/x86_64-conda_cos6-linux-gnu-g++"}}]' > /home/vscode/.local/share/CMakeTools/cmake-tools-kits.json \
&& echo '[{"name":"GCC-10","compilers":{"C":"/opt/conda/envs/petsird/bin/x86_64-conda_cos6-linux-gnu-gcc","CXX":"/opt/conda/envs/petsird/bin/x86_64-conda_cos6-linux-gnu-g++"}}]' > /home/vscode/.local/share/CMakeTools/cmake-tools-kits.json \
&& chown vscode:conda /home/vscode/.local/share/CMakeTools/cmake-tools-kits.json

# Install the yardl tool
ARG YARDL_VERSION=0.3.2
ARG YARDL_VERSION=0.6.2
RUN wget --quiet "https://github.com/microsoft/yardl/releases/download/v${YARDL_VERSION}/yardl_${YARDL_VERSION}_linux_x86_64.tar.gz" \
&& tar -xzf "yardl_${YARDL_VERSION}_linux_x86_64.tar.gz" \
&& mv yardl "/opt/conda/envs/${CONDA_ENVIRONMENT_NAME}/bin/" \
Expand Down
3 changes: 1 addition & 2 deletions .devcontainer/devcontainer.bashrc
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,8 @@
# shellcheck source=/dev/null

source /opt/conda/etc/profile.d/conda.sh
conda activate prd
conda activate petsird
source <(yardl completion bash)
source <(just --completions bash)

if [[ "${BASH_ENV:-}" == "$(readlink -f "${BASH_SOURCE[0]:-}")" ]]; then
# We don't want subshells to unnecessarily source this again.
Expand Down
21 changes: 9 additions & 12 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
// For format details, see https://aka.ms/devcontainer.json. For config options, see the README at:
// https://github.com/microsoft/vscode-dev-containerdevcotns/tree/v0.238.0/containers/go
// For format details, see https://aka.ms/devcontainer.json.
{
"name": "prd",
"name": "petsird",
"build": {
"dockerfile": "Dockerfile",
"context": ".."
Expand Down Expand Up @@ -48,7 +47,7 @@
"cmake.buildDirectory": "${workspaceFolder}/cpp/build",
"cmake.configureOnOpen": false,

"python.defaultInterpreterPath": "/opt/conda/envs/prd/bin/python",
"python.defaultInterpreterPath": "/opt/conda/envs/petsird/bin/python",
"python.analysis.typeCheckingMode": "strict",
"python.analysis.diagnosticMode": "workspace",
"python.analysis.diagnosticSeverityOverrides": {
Expand Down Expand Up @@ -88,7 +87,7 @@
"gitlens.showWhatsNewAfterUpgrades": false
},

"gcovViewer.gcovBinary": "/opt/conda/envs/prd/bin/x86_64-conda-linux-gnu-gcov",
"gcovViewer.gcovBinary": "/opt/conda/envs/petsird/bin/x86_64-conda-linux-gnu-gcov",
"gcovViewer.buildDirectories": ["${workspaceFolder}/cpp/build"],

"search.useIgnoreFiles": false,
Expand All @@ -109,19 +108,17 @@
"ms-python.python",
"ms-vscode.cmake-tools",
"ms-vscode.cpptools",
"sclu1034.justfile",
"timonwong.shellcheck",
"twxs.cmake"
]
}
},

// Use 'forwardPorts' to make a list of ports inside the container available locally.
// "forwardPorts": [],

// Use 'postCreateCommand' to run commands after the container is created.
// "postCreateCommand": "go version",
"overrideCommand": false,
"mounts": [
// Bind mount docker socket under an alias to support docker-from-docker
"source=/var/run/docker.sock,target=/var/run/docker-host.sock,type=bind"
],

// Comment out to connect as root instead. More info: https://aka.ms/vscode-remote/containers/non-root.
"remoteUser": "vscode"
}

0 comments on commit 08ef5aa

Please sign in to comment.