Skip to content

Commit

Permalink
Adding codespace devcontainer
Browse files Browse the repository at this point in the history
  • Loading branch information
mdavezac committed May 26, 2020
1 parent 07eeb28 commit ce22ceb
Show file tree
Hide file tree
Showing 6 changed files with 123 additions and 1 deletion.
30 changes: 30 additions & 0 deletions .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
#-------------------------------------------------------------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License. See https://go.microsoft.com/fwlink/?linkid=2090316 for license information.
#-------------------------------------------------------------------------------------------------------------

# To fully customize the contents of this image, use the following Dockerfile instead:
# https://github.com/microsoft/vscode-dev-containers/tree/v0.117.1/containers/codespaces-linux/.devcontainer/Dockerfile
FROM mcr.microsoft.com/vscode/devcontainers/universal:0-linux

# ** [Optional] Uncomment this section to install additional packages. **
#
ENV DEBIAN_FRONTEND=noninteractive
RUN sudo apt-get update \
&& sudo apt-get -y install --no-install-recommends \
build-essential gfortran gcc g++ quantum-espresso \
gfortran quantum-espresso quantum-espresso-data libopenmpi-dev \
make git cmake ninja-build \
#
# Clean up
&& sudo apt-get autoremove -y \
&& sudo apt-get clean -y \
&& sudo rm -rf /var/lib/apt/lists/*
ARG pyver=3.6
RUN /opt/python/${pyver}/bin/python -m venv /home/codespace/venv
RUN . /home/codespace/venv/bin/activate \
&& pip install --upgrade pip \
&& pip install setuptools wheel scikit-build "cmake!=3.16.3" ninja \
&& pip install cython numpy flake8 mypy black pytest \
&& pip install sphinx sphinx-autobuild rstcheck
ENV DEBIAN_FRONTEND=dialog
41 changes: 41 additions & 0 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
// For format details, see https://aka.ms/vscode-remote/devcontainer.json or this file's README at:
// https://github.com/microsoft/vscode-dev-containers/tree/v0.117.1/containers/codespaces-linux
{
"name": "Codespaces",
"dockerFile": "Dockerfile",
"remoteUser": "codespace",
"workspaceMount": "source=${localWorkspaceFolder},target=/home/codespace/workspace,type=bind,consistency=cached",
"workspaceFolder": "/home/codespace/workspace",
"runArgs": [
"--cap-add=SYS_PTRACE",
"--security-opt",
"seccomp=unconfined"
],
// Add the IDs of extensions you want installed when the container is created.
"extensions": [
"ms-vsonline.vsonline",
"GitHub.vscode-pull-request-github",
"MS-vsliveshare.vsliveshare",
"VisualStudioExptTeam.vscodeintellicode",
"ms-python.python",
"lextudio.restructuredtext",
"tcwalther.cython",
"twxs.cmake"
],
// Set *default* container specific settings.json values on container create.
"settings": {
"python.formatting.provider": "black",
"python.linting.pylintEnabled": false,
"python.linting.flake8Enabled": true,
"python.testing.pytestEnabled": true,
"python.pythonPath": "/home/codespace/venv/bin/python",
"python.venvFolders": [
"venv"
],
"cmake.cmakePath": "/home/codespace/venv/lib/python3.6/site-packages/cmake/data/bin/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": "uname -a"
}
47 changes: 47 additions & 0 deletions .devcontainer/symlinkDotNetCore.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
#!/nix/store/iqak4y6kxnjzz37idsffd2jha52wz31x-bash-4.4-p23/bin/bash
#--------------------------------------------------------------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License. See https://go.microsoft.com/fwlink/?linkid=2090316 for license information.
#--------------------------------------------------------------------------------------------------------------

set -ex

splitSdksDir="/opt/dotnet/sdks"

allSdksDir="/home/codespace/.dotnet"
mkdir -p "$allSdksDir"

# Copy latest muxer and license files
cp -f "$splitSdksDir/3/dotnet" "$allSdksDir"
cp -f "$splitSdksDir/3/LICENSE.txt" "$allSdksDir"
cp -f "$splitSdksDir/3/ThirdPartyNotices.txt" "$allSdksDir"

function createLinks() {
local sdkVersion="$1"
local runtimeVersion="$2"

cd "$splitSdksDir/$sdkVersion"

# Find folders with name as sdk or runtime version
find . -name "$sdkVersion" -o -name "$runtimeVersion" | while read subPath; do
# Trim beginning 2 characters from the line which currently looks like, for example, './sdk/2.2.402'
subPath="${subPath:2}"

linkFrom="$allSdksDir/$subPath"
linkFromParentDir=$(dirname $linkFrom)
mkdir -p "$linkFromParentDir"

linkTo="$splitSdksDir/$sdkVersion/$subPath"
ln -s $linkTo $linkFrom
done
}

createLinks "3.1.201" "3.1.3"
echo
createLinks "3.0.103" "3.0.3"
echo
createLinks "2.2.402" "2.2.7"
echo
createLinks "2.1.805" "2.1.17"
echo
createLinks "1.1.14" "1.1.13"
3 changes: 3 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
.venv/
.direnv/
_skbuild/
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -146,4 +146,4 @@ shell.nix
.local/
.vim/
.direnv/
.clang
.clang
1 change: 1 addition & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ def wrapped_setup(*args, **kwargs):
"nbformat",
"ipykernel",
"IPython",
"black",
]
if version_info[0] == 2:
tests_require.append("mock")
Expand Down

0 comments on commit ce22ceb

Please sign in to comment.