Skip to content

Commit

Permalink
Better devcontainers (#280)
Browse files Browse the repository at this point in the history
* Better fantomas on build

* Better devcontainers
  • Loading branch information
TheAngryByrd committed Oct 6, 2023
1 parent a717b3c commit 9c804e4
Show file tree
Hide file tree
Showing 15 changed files with 258 additions and 243 deletions.
43 changes: 10 additions & 33 deletions .devcontainer/Dockerfile
@@ -1,40 +1,17 @@
FROM debian:buster-slim


RUN apt-get update \
&& apt-get install -y --no-install-recommends \
ca-certificates \
\
# .NET Core dependencies
libc6 \
libgcc1 \
libgssapi-krb5-2 \
libicu63 \
libssl1.1 \
libstdc++6 \
zlib1g \
curl \
git \
procps \
wget \
&& rm -rf /var/lib/apt/lists/*
# [Choice] Debian version (use bullseye on local arm64/Apple Silicon): bookworm, bullseye, buster
ARG VARIANT="bookworm"
FROM buildpack-deps:${VARIANT}-curl


ENV \
# Enable detection of running in a container
DOTNET_RUNNING_IN_CONTAINER=true \
DOTNET_INSTALL_DIR=/usr/share/dotnet/ \
DOTNET_ROOT=/usr/share/dotnet/

COPY ./.devcontainer/install-dotnets.sh global.json* .

RUN /bin/bash install-dotnets.sh

ENV PATH="$DOTNET_ROOT:${PATH}"
RUN ln -s /usr/share/dotnet/dotnet /usr/bin/dotnet
DOTNET_ROOT=/usr/share/dotnet/ \
DOTNET_NOLOGO=true \
DOTNET_CLI_TELEMETRY_OPTOUT=false\
DOTNET_USE_POLLING_FILE_WATCHER=true

RUN dotnet --info

# Copy endpoint specific user settings into container to specify
# .NET Core should be used as the runtime.
COPY ./.devcontainer/settings.vscode.json /root/.vscode-remote/data/Machine/settings.json
# [Optional] Uncomment this section to install additional OS packages.
# RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \
# && apt-get -y install --no-install-recommends <your-package-list-here>
85 changes: 71 additions & 14 deletions .devcontainer/devcontainer.json
@@ -1,16 +1,73 @@
{
"name": "dotnet",
// Set the build context one level higher so we can grab metadata like global.json
"context": "..",
"dockerFile": "Dockerfile",
"forwardPorts": [
0
],
"extensions": [
"ionide.ionide-fsharp",
"ms-dotnettools.csharp",
"editorconfig.editorconfig",
"ionide.ionide-paket",
"ionide.ionide-fake"
]
"name": "dotnet",
// Set the build context one level higher so we can grab metadata like global.json
"context": "..",
"dockerFile": "Dockerfile",
"forwardPorts": [
0
],
"features": {
// https://github.com/devcontainers/features/blob/main/src/common-utils/README.md
"ghcr.io/devcontainers/features/common-utils:2": {
"installZsh": true,
"installOhMyZshConfig": true,
"configureZshAsDefaultShell": true,
"username": "vscode",
"userUid": "1000",
"userGid": "1000",
"upgradePackages": true
},
// https://github.com/devcontainers/features/blob/main/src/github-cli/README.md
"ghcr.io/devcontainers/features/github-cli:1": {},
// https://github.com/devcontainers-contrib/features/blob/main/src/starship/README.md
"ghcr.io/devcontainers-contrib/features/starship:1": {},
// https://github.com/devcontainers/features/blob/main/src/dotnet/README.md
"ghcr.io/devcontainers/features/dotnet:2": {
"version": "7.0",
"additionalVersions": "6.0"
}
},
"overrideFeatureInstallOrder": [
"ghcr.io/devcontainers/features/common-utils",
"ghcr.io/devcontainers/features/github-cli",
"ghcr.io/devcontainers-contrib/features/starship",
"ghcr.io/devcontainers/features/dotnet"
],
"customizations": {
"vscode": {
// Add the IDs of extensions you want installed when the container is created.
"extensions": [
"ms-dotnettools.csharp",
"Ionide.Ionide-fsharp",
"tintoy.msbuild-project-tools",
"ionide.ionide-paket",
"usernamehw.errorlens",
"alefragnani.Bookmarks",
"oderwat.indent-rainbow",
"vscode-icons-team.vscode-icons",
"EditorConfig.EditorConfig",
"ms-azuretools.vscode-docker",
"GitHub.vscode-pull-request-github",
"github.vscode-github-actions"
],
"settings": {
"terminal.integrated.defaultProfile.linux": "zsh",
"csharp.suppressDotnetInstallWarning": true
}
}
},
"remoteUser": "vscode",
"containerUser": "vscode",
"containerEnv": {
// Expose the local environment variable to the container
// They are used for releasing and publishing from the container
"GITHUB_TOKEN": "${localEnv:GITHUB_TOKEN}"
},
"onCreateCommand": {
"enable-starship": "echo 'eval \"$(starship init zsh)\"' >> ~/.zshrc"
},
"postAttachCommand": {
"restore": "dotnet tool restore && dotnet restore"
},
"waitFor": "updateContentCommand"
}
23 changes: 0 additions & 23 deletions .devcontainer/install-dotnets.sh

This file was deleted.

7 changes: 0 additions & 7 deletions .devcontainer/settings.vscode.json

This file was deleted.

43 changes: 10 additions & 33 deletions Content/Console/.devcontainer/Dockerfile
@@ -1,40 +1,17 @@
FROM debian:buster-slim


RUN apt-get update \
&& apt-get install -y --no-install-recommends \
ca-certificates \
\
# .NET Core dependencies
libc6 \
libgcc1 \
libgssapi-krb5-2 \
libicu63 \
libssl1.1 \
libstdc++6 \
zlib1g \
curl \
git \
procps \
wget \
&& rm -rf /var/lib/apt/lists/*
# [Choice] Debian version (use bullseye on local arm64/Apple Silicon): bookworm, bullseye, buster
ARG VARIANT="bookworm"
FROM buildpack-deps:${VARIANT}-curl


ENV \
# Enable detection of running in a container
DOTNET_RUNNING_IN_CONTAINER=true \
DOTNET_INSTALL_DIR=/usr/share/dotnet/ \
DOTNET_ROOT=/usr/share/dotnet/

COPY ./.devcontainer/install-dotnets.sh global.json* ./

RUN /bin/bash install-dotnets.sh

ENV PATH="$DOTNET_ROOT:${PATH}"
RUN ln -s /usr/share/dotnet/dotnet /usr/bin/dotnet
DOTNET_ROOT=/usr/share/dotnet/ \
DOTNET_NOLOGO=true \
DOTNET_CLI_TELEMETRY_OPTOUT=false\
DOTNET_USE_POLLING_FILE_WATCHER=true

RUN dotnet --info

# Copy endpoint specific user settings into container to specify
# .NET Core should be used as the runtime.
COPY ./.devcontainer/settings.vscode.json /root/.vscode-remote/data/Machine/settings.json
# [Optional] Uncomment this section to install additional OS packages.
# RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \
# && apt-get -y install --no-install-recommends <your-package-list-here>
85 changes: 71 additions & 14 deletions Content/Console/.devcontainer/devcontainer.json
@@ -1,16 +1,73 @@
{
"name": "dotnet",
// Set the build context one level higher so we can grab metadata like global.json
"context": "..",
"dockerFile": "Dockerfile",
"forwardPorts": [
0
],
"extensions": [
"ionide.ionide-fsharp",
"ms-dotnettools.csharp",
"editorconfig.editorconfig",
"ionide.ionide-paket",
"ionide.ionide-fake"
]
"name": "dotnet",
// Set the build context one level higher so we can grab metadata like global.json
"context": "..",
"dockerFile": "Dockerfile",
"forwardPorts": [
0
],
"features": {
// https://github.com/devcontainers/features/blob/main/src/common-utils/README.md
"ghcr.io/devcontainers/features/common-utils:2": {
"installZsh": true,
"installOhMyZshConfig": true,
"configureZshAsDefaultShell": true,
"username": "vscode",
"userUid": "1000",
"userGid": "1000",
"upgradePackages": true
},
// https://github.com/devcontainers/features/blob/main/src/github-cli/README.md
"ghcr.io/devcontainers/features/github-cli:1": {},
// https://github.com/devcontainers-contrib/features/blob/main/src/starship/README.md
"ghcr.io/devcontainers-contrib/features/starship:1": {},
// https://github.com/devcontainers/features/blob/main/src/dotnet/README.md
"ghcr.io/devcontainers/features/dotnet:2": {
"version": "7.0",
"additionalVersions": "6.0"
}
},
"overrideFeatureInstallOrder": [
"ghcr.io/devcontainers/features/common-utils",
"ghcr.io/devcontainers/features/github-cli",
"ghcr.io/devcontainers-contrib/features/starship",
"ghcr.io/devcontainers/features/dotnet"
],
"customizations": {
"vscode": {
// Add the IDs of extensions you want installed when the container is created.
"extensions": [
"ms-dotnettools.csharp",
"Ionide.Ionide-fsharp",
"tintoy.msbuild-project-tools",
"ionide.ionide-paket",
"usernamehw.errorlens",
"alefragnani.Bookmarks",
"oderwat.indent-rainbow",
"vscode-icons-team.vscode-icons",
"EditorConfig.EditorConfig",
"ms-azuretools.vscode-docker",
"GitHub.vscode-pull-request-github",
"github.vscode-github-actions"
],
"settings": {
"terminal.integrated.defaultProfile.linux": "zsh",
"csharp.suppressDotnetInstallWarning": true
}
}
},
"remoteUser": "vscode",
"containerUser": "vscode",
"containerEnv": {
// Expose the local environment variable to the container
// They are used for releasing and publishing from the container
"GITHUB_TOKEN": "${localEnv:GITHUB_TOKEN}"
},
"onCreateCommand": {
"enable-starship": "echo 'eval \"$(starship init zsh)\"' >> ~/.zshrc"
},
"postAttachCommand": {
"restore": "dotnet tool restore && dotnet restore"
},
"waitFor": "updateContentCommand"
}
23 changes: 0 additions & 23 deletions Content/Console/.devcontainer/install-dotnets.sh

This file was deleted.

7 changes: 0 additions & 7 deletions Content/Console/.devcontainer/settings.vscode.json

This file was deleted.

9 changes: 5 additions & 4 deletions Content/Console/Directory.Build.targets
Expand Up @@ -7,8 +7,8 @@ See https://learn.microsoft.com/en-us/visualstudio/msbuild/customize-by-director
<PropertyGroup>
<_BuildProjBaseIntermediateOutputPath>$(MSBuildThisFileDirectory)build/obj/</_BuildProjBaseIntermediateOutputPath>
<_DotnetToolManifestFile>$(MSBuildThisFileDirectory).config/dotnet-tools.json</_DotnetToolManifestFile>
<_DotnetToolRestoreOutputFile>$(_BuildProjBaseIntermediateOutputPath)/dotnet-tool-restore-$(NETCoreSdkVersion)</_DotnetToolRestoreOutputFile>
<_DotnetFantomasOutputFile>$(BaseIntermediateOutputPath)dotnet-fantomas-msbuild</_DotnetFantomasOutputFile>
<_DotnetToolRestoreOutputFile>$(_BuildProjBaseIntermediateOutputPath)/dotnet-tool-restore-$(NETCoreSdkVersion)-$(OS)</_DotnetToolRestoreOutputFile>
<_DotnetFantomasOutputFile>$(BaseIntermediateOutputPath)dotnet-fantomas-msbuild-$(NETCoreSdkVersion)-$(OS)</_DotnetFantomasOutputFile>
</PropertyGroup>

<!-- Make sure that dotnet tools (including paket) are restored before restoring any project -->
Expand All @@ -19,8 +19,9 @@ See https://learn.microsoft.com/en-us/visualstudio/msbuild/customize-by-director
</Target>

<!-- Make sure that files are formatted before building -->
<Target Name="Format" BeforeTargets="BeforeBuild" Inputs="@(Compile)" Outputs="$(_DotnetFantomasOutputFile)" >
<Exec Command="dotnet fantomas $(MSBuildProjectDirectory)" StandardOutputImportance="High" StandardErrorImportance="High" WorkingDirectory="$(MSBuildThisFileDirectory)" />
<Target Name="Format" Condition=" '$(MSBuildProjectExtension)' == '.fsproj' AND '$(DesignTimeBuild)' != 'true' " BeforeTargets="BeforeBuild" Inputs="@(Compile)" Outputs="$(_DotnetFantomasOutputFile)" >
<Exec Command="dotnet fantomas $(MSBuildProjectDirectory)" StandardOutputImportance="High" StandardErrorImportance="High" WorkingDirectory="$(MSBuildThisFileDirectory)" ContinueOnError="WarnAndContinue" />
<Touch Files="$(_DotnetFantomasOutputFile)" AlwaysCreate="True" ForceTouch="True" />
</Target>

</Project>

0 comments on commit 9c804e4

Please sign in to comment.