Skip to content

Commit

Permalink
migrations: use open devcontainers spec and container lifecylce hooks
Browse files Browse the repository at this point in the history
this changeset is to replace to vscode remote container with the new open dev containers specification.

- replace devcontainer.json with open spec
- upgrade dependencies to the latest minor
- delete the docker version and the external zsh script
- install dev-certs via container lifecycle hooks
- restore via container lifecycle hooks
  • Loading branch information
kosalaperera authored Mar 24, 2023
1 parent 551f9fc commit f4cf89d
Show file tree
Hide file tree
Showing 8 changed files with 144 additions and 176 deletions.
4 changes: 0 additions & 4 deletions .devcontainer/Dockerfile

This file was deleted.

208 changes: 121 additions & 87 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -1,97 +1,131 @@
{
"name": "C# (.NET)",
"dockerComposeFile": "docker-compose.yml",
"service": "api",
"workspaceFolder": "/workspace",
"name": "dotnet",

// See complete list https://hub.docker.com/_/microsoft-dotnet-sdk/
// Or https://mcr.microsoft.com/v2/dotnet/sdk/tags/list
"image": "mcr.microsoft.com/dotnet/sdk:6.0",

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

// Uncomment to connect as root instead. More info: https://aka.ms/dev-containers-non-root.
"remoteUser": "root",

// Add more features. See complete list https://github.com/devcontainers/features
"features": {
"common": {
"username": "automatic",
"uid": "automatic",
"gid": "automatic",
"installZsh": true,
"upgradePackages": true,
"ghcr.io/devcontainers/features/common-utils:2": {
"configureZshAsDefaultShell": true
},
"github-cli": "latest",
// "node": {
// "version": "lts",
// "nodeGypDependencies": true
// },
"azure-cli": "latest"
},
// Set *default* container specific settings.json values on container create.
"settings": {
"files.associations": {
"**/ci/*.yml": "azure-pipelines"
"ghcr.io/devcontainers/features/github-cli:1": {},
"ghcr.io/devcontainers/features/powershell:1": {},
"ghcr.io/devcontainers/features/docker-outside-of-docker:1": {
"moby": false,
"dockerDashComposeVersion": "v2"
},
"omnisharp.enableAsyncCompletion": true,
"omnisharp.enableImportCompletion": true,
"omnisharp.enableRoslynAnalyzers": true,
"omnisharp.organizeImportsOnFormat": true,
"omnisharp.useEditorFormattingSettings": true,
"omnisharp.useModernNet": true,
"razor.disabled": true,
"terminal.integrated.defaultProfile.linux": "zsh",
},
"ghcr.io/devcontainers/features/kubectl-helm-minikube:1": {
"minikube": "none"
},
"ghcr.io/devcontainers/features/node:1": {},
"ghcr.io/devcontainers/features/azure-cli:1": {}
},
"containerEnv": {
// Set ASP.NET environment settings.
"ASPNETCORE_URLS": "https://+:5001;http://+:5000",
"ASPNETCORE_ENVIRONMENT": "Development",
// Set dotnet CLI environment settings.
"DOTNET_CLI_TELEMETRY_OPTOUT": "1",
"DOTNET_GENERATE_ASPNET_CERTIFICATE": "1",
"DOTNET_NOLOGO": "1"
},
// Configure tool-specific properties.
"customizations": {
// Configure properties specific to VS Code.
"vscode": {
// Add the IDs of extensions you want installed when the container is created.
"extensions": [
"visualstudioexptteam.vscodeintellicode-insiders",
"visualstudiotxptteam.vscodeintellicode-completions",
"ms-dotnettools.csharp",
"ms-dotnettools.vscode-dotnet-runtime",
"ms-dotnettools.dotnet-interactive-vscode",

// Add the IDs of extensions you want installed when the container is created.
"extensions": [
"visualstudioexptteam.vscodeintellicode",
"VisualStudioExptTeam.vscodeintellicode-completions",
"ms-dotnettools.csharp",
"ms-dotnettools.vscode-dotnet-runtime",
"ms-edgedevtools.vscode-edge-devtools",

"humao.rest-client",

"ms-vscode.azurecli",
"ms-azure-devops.azure-pipelines",
"ms-azuretools.vscode-azureresourcegroups",
"ms-azuretools.vscode-azureappservice",
"ms-azuretools.vscode-azurevirtualmachines",

"ms-dotnettools.dotnet-interactive-vscode",

"ms-vscode.wordcount",
"editorconfig.editorconfig",
"esbenp.prettier-vscode",
"streetsidesoftware.code-spell-checker",
"redhat.fabric8-analytics",
"redhat.vscode-yaml",
"bierner.github-markdown-preview",
],
"usernamehw.errorlens",
"editorconfig.editorconfig",

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

// [Optional] To reuse of your local HTTPS dev cert:
//
// 1. Export it locally using this command:
// * Windows PowerShell:
// dotnet dev-certs https --trust; dotnet dev-certs https -ep "$env:USERPROFILE/.aspnet/https/aspnetapp.pfx" -p "SecurePwdGoesHere"
// * macOS/Linux terminal:
// dotnet dev-certs https --trust; dotnet dev-certs https -ep "${HOME}/.aspnet/https/aspnetapp.pfx" -p "SecurePwdGoesHere"
//
// 2. Uncomment these 'remoteEnv' lines:
// "remoteEnv": {
// "ASPNETCORE_Kestrel__Certificates__Default__Password": "SecurePwdGoesHere",
// "ASPNETCORE_Kestrel__Certificates__Default__Path": "/home/vscode/.aspnet/https/aspnetapp.pfx",
// },
//
// 3. Do one of the following depending on your scenario:
// * When using GitHub Codespaces and/or Remote - Containers:
// 1. Start the container
// 2. Drag ~/.aspnet/https/aspnetapp.pfx into the root of the file explorer
// 3. Open a terminal in VS Code and run "mkdir -p /home/vscode/.aspnet/https && mv aspnetapp.pfx /home/vscode/.aspnet/https"
//
// * If only using Remote - Containers with a local container, uncomment this line instead:
// "mounts": [ "source=${env:HOME}${env:USERPROFILE}/.aspnet/https,target=/home/vscode/.aspnet/https,type=bind" ],
"ms-vscode.azurecli",
"ms-azuretools.vscode-docker",
"ms-kubernetes-tools.vscode-kubernetes-tools",
"ms-kubernetes-tools.vscode-aks-tools",
"ms-kubernetes-tools.aks-devx-tools",
"ms-azuretools.vscode-azurecontainerapps",
"ms-azuretools.vscode-bicep",
"bencoleman.armview",
"redhat.vscode-yaml",
"ms-vscode.vscode-node-azure-pack",
"ms-azuretools.vscode-azureserverlesspack",

// Use 'postCreateCommand' to run commands after the container is created.
"postCreateCommand": "zsh .devcontainer/post-create.zsh",
// Uncomment to indicates whether VS Code should stop the containers when the VS Code window is closed / shut down. Values are "none" and "stopCompose" (default).
"shutdownAction": "stopCompose",
"ms-azure-devops.azure-pipelines",

"bierner.github-markdown-preview",

// This ext is bundled with mssql and will be installed automatically.
// Database projects can be handled via Azure Data Studio.
// "ms-mssql.sql-database-projects-vscode",
"ms-mssql.mssql",

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

"ms-vscode.wordcount",
"streetsidesoftware.code-spell-checker",
"redhat.fabric8-analytics"
],
// Set *default* container specific settings.json values on container create.
"settings": {
"terminal.integrated.defaultProfile.linux": "zsh",

"editor.formatOnPaste": true,
"editor.guides.bracketPairs": "active",
"debug.internalConsoleOptions": "neverOpen",

"scm.defaultViewMode": "tree",

"files.watcherExclude": {
"**/bin/**": true,
"**/obj/**": true,
},
"files.associations": {
"**/ci/*.yml": "azure-pipelines"
},

"omnisharp.enableAsyncCompletion": true,
"omnisharp.enableImportCompletion": true,
"omnisharp.enableRoslynAnalyzers": true,
"omnisharp.organizeImportsOnFormat": true,
"omnisharp.useEditorFormattingSettings": true,
"omnisharp.enableEditorConfigSupport": true,
// Fix for ARM-based devices.
// Read more https://github.com/OmniSharp/omnisharp-vscode/issues/4348#issuecomment-1003867594
"omnisharp.path": "latest",
"omnisharp.sdkIncludePrereleases": true,
"omnisharp.useModernNet": true,

"razor.disabled": true
}
}
},

// Use 'updateContentCommand' to run commands after the container is successfully created.
"updateContentCommand": {
"dev-certs": "dotnet dev-certs https --clean && dotnet dev-certs https -t",
"clean": "rm -rf **/bin **/obj"
},
// Use 'postCreateCommand' to run commands after the container is created.
"postCreateCommand": {
"restore": "dotnet restore --no-cache --force"
}
}
61 changes: 0 additions & 61 deletions .devcontainer/docker-compose.yml

This file was deleted.

12 changes: 0 additions & 12 deletions .devcontainer/post-create.zsh

This file was deleted.

25 changes: 18 additions & 7 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -1,16 +1,27 @@
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
// Use IntelliSense to find out which attributes exist for C# debugging
// Use hover for the description of the existing attributes
// For further information visit https://github.com/OmniSharp/omnisharp-vscode/blob/master/debugger-launchjson.md
"name": ".NET Launch (web)",
"type": "coreclr",
"request": "launch",
"program": "dotnet",
"args": ["run"],
"cwd": "${workspaceFolder}/Services",
}
"preLaunchTask": "build",
// If you have changed target frameworks, make sure to update the program path.
"program": "${workspaceFolder}/Services/bin/Debug/net6.0/Skol.Services.dll",
"args": [],
"cwd": "${workspaceFolder}/Services/",
"stopAtEntry": false,
// Enable launching a web browser when ASP.NET Core starts. For more information: https://aka.ms/VSCode-CS-LaunchJson-WebBrowser
"serverReadyAction": {
"action": "openExternally",
"pattern": "\\bNow listening on:\\s+(https?://\\S+)"
},
"env": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
},
]
}
2 changes: 1 addition & 1 deletion Application/Skol.Application.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

<ItemGroup>
<PackageReference Include="MediatR.Extensions.Microsoft.DependencyInjection" Version="9.0.0" />
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="6.0.0-preview.3.21201.2" />
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="6.0.15" />
</ItemGroup>

<ItemGroup>
Expand Down
2 changes: 1 addition & 1 deletion Infrastructure/Skol.Infrastructure.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.EntityFrameworkCore.InMemory" Version="6.0.0-preview.3.21201.2" />
<PackageReference Include="Microsoft.EntityFrameworkCore.InMemory" Version="6.0.15" />
</ItemGroup>

<ItemGroup>
Expand Down
6 changes: 3 additions & 3 deletions Services/Skol.Services.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="6.0.0-preview.3.21201.13" NoWarn="NU1605" />
<PackageReference Include="Microsoft.AspNetCore.Authentication.OpenIdConnect" Version="6.0.0-preview.3.21201.13" NoWarn="NU1605" />
<PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="6.0.15" NoWarn="NU1605" />
<PackageReference Include="Microsoft.AspNetCore.Authentication.OpenIdConnect" Version="6.0.15" NoWarn="NU1605" />
<PackageReference Include="Microsoft.AspnetCore.Mvc.Versioning" Version="5.0.0" />
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.1.4" />
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.5.0" />
</ItemGroup>

<ItemGroup>
Expand Down

0 comments on commit f4cf89d

Please sign in to comment.