Skip to content

Commit 2c21520

Browse files
committed
Add devcontainer
1 parent ef10b73 commit 2c21520

File tree

7 files changed

+105
-77
lines changed

7 files changed

+105
-77
lines changed

.devcontainer/Dockerfile

Lines changed: 9 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,43 +1,16 @@
1-
FROM debian:buster-slim
1+
# [Choice] Debian version (use bullseye on local arm64/Apple Silicon): bookworm, bullseye, buster
2+
ARG VARIANT="bookworm"
3+
FROM buildpack-deps:${VARIANT}-curl
24

35

4-
RUN apt-get update \
5-
&& apt-get install -y --no-install-recommends \
6-
ca-certificates \
7-
\
8-
# .NET Core dependencies
9-
libc6 \
10-
libgcc1 \
11-
libgssapi-krb5-2 \
12-
libicu63 \
13-
libssl1.1 \
14-
libstdc++6 \
15-
zlib1g \
16-
curl \
17-
git \
18-
procps \
19-
wget \
20-
nodejs \
21-
npm \
22-
&& rm -rf /var/lib/apt/lists/*
23-
24-
RUN wget -qO- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.3/install.sh | bash
25-
266
ENV \
277
# Enable detection of running in a container
288
DOTNET_RUNNING_IN_CONTAINER=true \
29-
DOTNET_INSTALL_DIR=/usr/share/dotnet/ \
30-
DOTNET_ROOT=/usr/share/dotnet/
31-
32-
COPY ./.devcontainer/install-dotnets.sh global.json* .
33-
34-
RUN /bin/bash install-dotnets.sh
35-
36-
ENV PATH="$DOTNET_ROOT:${PATH}"
37-
RUN ln -s /usr/share/dotnet/dotnet /usr/bin/dotnet
9+
DOTNET_ROOT=/usr/share/dotnet/ \
10+
DOTNET_NOLOGO=true \
11+
DOTNET_CLI_TELEMETRY_OPTOUT=false
3812

39-
RUN dotnet --info
4013

41-
# Copy endpoint specific user settings into container to specify
42-
# .NET Core should be used as the runtime.
43-
COPY ./.devcontainer/settings.vscode.json /root/.vscode-remote/data/Machine/settings.json
14+
# [Optional] Uncomment this section to install additional OS packages.
15+
# RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \
16+
# && apt-get -y install --no-install-recommends <your-package-list-here>

.devcontainer/devcontainer.json

Lines changed: 77 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,79 @@
11
{
2-
"name": "dotnet",
3-
// Set the build context one level higher so we can grab metadata like global.json
4-
"context": "..",
5-
"dockerFile": "Dockerfile",
6-
"forwardPorts": [
7-
0
8-
],
9-
"extensions": [
10-
"ionide.ionide-fsharp",
11-
"ms-dotnettools.csharp",
12-
"editorconfig.editorconfig",
13-
"ionide.ionide-paket",
14-
"ionide.ionide-fake"
15-
]
2+
"name": "dotnet",
3+
// Set the build context one level higher so we can grab metadata like global.json
4+
"context": "..",
5+
"dockerFile": "Dockerfile",
6+
"forwardPorts": [
7+
0
8+
],
9+
"features": {
10+
// https://github.com/devcontainers/features/blob/main/src/common-utils/README.md
11+
"ghcr.io/devcontainers/features/common-utils:2": {
12+
"installZsh": true,
13+
"installOhMyZshConfig": true,
14+
"configureZshAsDefaultShell": true,
15+
"username": "vscode",
16+
"userUid": "1000",
17+
"userGid": "1000",
18+
"upgradePackages": true
19+
},
20+
// https://github.com/devcontainers/features/blob/main/src/github-cli/README.md
21+
"ghcr.io/devcontainers/features/github-cli:1": {},
22+
// https://github.com/devcontainers-contrib/features/blob/main/src/starship/README.md
23+
"ghcr.io/devcontainers-contrib/features/starship:1": {},
24+
// https://github.com/devcontainers/features/blob/main/src/dotnet/README.md
25+
"ghcr.io/devcontainers/features/dotnet:2": {
26+
"version": "7.0",
27+
"additionalVersions": "6.0"
28+
},
29+
"ghcr.io/devcontainers/features/node:1": {
30+
"version": "18"
31+
},
32+
"ghcr.io/devcontainers/features/python:1": {
33+
"version": "3.10"
34+
}
35+
},
36+
"overrideFeatureInstallOrder": [
37+
"ghcr.io/devcontainers/features/common-utils",
38+
"ghcr.io/devcontainers/features/github-cli",
39+
"ghcr.io/devcontainers-contrib/features/starship",
40+
"ghcr.io/devcontainers/features/dotnet"
41+
],
42+
"customizations": {
43+
"vscode": {
44+
// Add the IDs of extensions you want installed when the container is created.
45+
"extensions": [
46+
"ms-dotnettools.csharp",
47+
"Ionide.Ionide-fsharp",
48+
"tintoy.msbuild-project-tools",
49+
"ionide.ionide-paket",
50+
"usernamehw.errorlens",
51+
"alefragnani.Bookmarks",
52+
"oderwat.indent-rainbow",
53+
"vscode-icons-team.vscode-icons",
54+
"EditorConfig.EditorConfig",
55+
"ms-azuretools.vscode-docker",
56+
"GitHub.vscode-pull-request-github",
57+
"github.vscode-github-actions"
58+
],
59+
"settings": {
60+
"terminal.integrated.defaultProfile.linux": "zsh",
61+
"csharp.suppressDotnetInstallWarning": true
62+
}
63+
}
64+
},
65+
"remoteUser": "vscode",
66+
"containerUser": "vscode",
67+
"containerEnv": {
68+
// Expose the local environment variable to the container
69+
// They are used for releasing and publishing from the container
70+
"GITHUB_TOKEN": "${localEnv:GITHUB_TOKEN}"
71+
},
72+
"onCreateCommand": {
73+
"enable-starship": "echo 'eval \"$(starship init zsh)\"' >> ~/.zshrc"
74+
},
75+
"postAttachCommand": {
76+
"restore": "dotnet tool restore && dotnet restore"
77+
},
78+
"waitFor": "updateContentCommand"
1679
}

.devcontainer/install-dotnets.sh

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

.devcontainer/settings.vscode.json

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

.github/workflows/build.yml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,5 +112,16 @@ jobs:
112112
env:
113113
CI: true
114114

115+
# Builds the project in a dev container
116+
build-devcontainer:
117+
runs-on: ubuntu-latest
118+
steps:
115119

120+
- uses: actions/checkout@v3
116121

122+
- name: Build and run dev container task
123+
uses: devcontainers/[email protected]
124+
with:
125+
runCmd: |
126+
chmod +x ./build.sh
127+
./build.sh RunTests

build/build.fs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,12 +126,17 @@ let checkFormatCode _ =
126126

127127
let clean _ =
128128
!! "bin"
129+
++ "benchmarks/**/bin"
129130
++ "src/**/bin"
130131
++ "tests/**/bin"
132+
++ "tools/**/bin"
133+
++ "benchmarks/**/obj"
131134
++ "src/**/obj"
132135
++ "tests/**/obj"
136+
++ "tools/**/obj"
133137
++ "dist"
134138
++ "js-dist"
139+
++ "**/.python-tests"
135140
|> Shell.cleanDirs
136141

137142
[ "paket-files/paket.restore.cached" ]

global.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
{
22
"sdk": {
3-
"version": "7.0.201"
3+
"version": "7.0.201",
4+
"rollForward": "latestMinor"
45
}
5-
}
6+
}

0 commit comments

Comments
 (0)