Skip to content

Commit

Permalink
feat: add devcontainer configuration with support for pwsh as default…
Browse files Browse the repository at this point in the history
… prompt
  • Loading branch information
sheldonhull committed Jul 27, 2020
1 parent 24b7b9a commit a508ff5
Show file tree
Hide file tree
Showing 4 changed files with 121 additions and 0 deletions.
30 changes: 30 additions & 0 deletions .devcontainer/Dockerfile
@@ -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.128.0/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 -qqy \
&& sudo apt-get -qqy install --no-install-recommends wget
# Install PowerShell 7
RUN sudo wget https://packages.microsoft.com/config/debian/10/packages-microsoft-prod.deb \
&& sudo dpkg -i packages-microsoft-prod.deb \
&& sudo rm packages-microsoft-prod.deb \
&& sudo apt-get -qqy update \
&& sudo apt-get -qqy install powershell

# RUN wget -q https://packages.microsoft.com/config/ubuntu/18.04/packages-microsoft-prod.deb \
# && sudo dpkg -i packages-microsoft-prod.deb && sudo apt-get -qqy update \
# && sudo apt-get install -y powershell

# Update the list of products
# RUN sudo apt-get update

# Enable the "universe" repositories
# RUN sudo add-apt-repository universe
34 changes: 34 additions & 0 deletions .devcontainer/devcontainer.json
@@ -0,0 +1,34 @@
// 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.128.0/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"
],
"settings": {
"terminal.integrated.shell.linux": "/opt/microsoft/powershell/7/pwsh"
},
// Set *default* container specific settings.json values on container create.
// "settings": {},
// 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"
,"pwsh --version"
// ,"pwsh -c ./.devcontainer/init.ps1" // this should be done by dotfiles repo
]
}
10 changes: 10 additions & 0 deletions .devcontainer/git-ed.sh
@@ -0,0 +1,10 @@
#!/usr/bin/env bash

if [[ $(which code-insiders) && ! $(which code) ]]; then
GIT_ED="code-insiders"
else
GIT_ED="code"
fi

$GIT_ED --wait $@

47 changes: 47 additions & 0 deletions .devcontainer/symlinkDotNetCore.sh
@@ -0,0 +1,47 @@
#!/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.202" "3.1.4"
echo
createLinks "3.0.103" "3.0.3"
echo
createLinks "2.2.402" "2.2.7"
echo
createLinks "2.1.806" "2.1.17"
echo
createLinks "1.1.14" "1.1.13"

0 comments on commit a508ff5

Please sign in to comment.