-
Notifications
You must be signed in to change notification settings - Fork 720
Enable devcontainers in repo. #6491
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
fc560d3
DevContainer initial commit.
mitchdenny 956663b
WIP
mitchdenny 6afb544
WIP: devcontainer walkthrough.
mitchdenny 0637d5e
Changes.
mitchdenny 51e8389
Set host requirements.
mitchdenny 91ea30d
Fix codespace test so it can run under codespaces.
mitchdenny 56fa242
Introduce Codespaces options.
mitchdenny c87e7d9
Map Redis playground ports.
mitchdenny b23ccb1
Update src/Aspire.Hosting/Codespaces/CodespacesOptions.cs
mitchdenny d3ff895
Update src/Aspire.Hosting/Codespaces/CodespacesOptions.cs
mitchdenny b0edc56
Update src/Aspire.Hosting/Codespaces/CodespacesOptions.cs
mitchdenny 5bde6d6
Update src/Aspire.Hosting/Codespaces/CodespacesOptions.cs
mitchdenny b1f3fdb
Update src/Aspire.Hosting/Codespaces/CodespacesOptions.cs
mitchdenny 8ae2a44
Change when command runs to improve reliability.
mitchdenny ec128aa
Syntax error.
mitchdenny c96a2a0
Remove public API.
mitchdenny File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,94 @@ | ||
| // For format details, see https://aka.ms/devcontainer.json. For config options, see the | ||
| // README at: https://github.com/devcontainers/templates/tree/main/src/dotnet | ||
| { | ||
| "name": "C# (.NET)", | ||
| // Or use a Dockerfile or Docker Compose file. More info: https://containers.dev/guide/dockerfile | ||
| "image": "mcr.microsoft.com/devcontainers/dotnet:1-9.0", | ||
| "features": { | ||
| "ghcr.io/devcontainers/features/azure-cli:1": {}, | ||
| "ghcr.io/azure/azure-dev/azd:0": {}, | ||
| "ghcr.io/devcontainers/features/docker-in-docker": {}, | ||
mitchdenny marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| "ghcr.io/devcontainers/features/dotnet": { | ||
mitchdenny marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| "additionalVersions": [ | ||
| "8.0.403" | ||
| ] | ||
| } | ||
| }, | ||
|
|
||
| "hostRequirements": { | ||
mitchdenny marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| "cpus": 8, | ||
| "memory": "32gb", | ||
| "storage": "64gb" | ||
| }, | ||
|
|
||
| // Features to add to the dev container. More info: https://containers.dev/features. | ||
| // "features": {}, | ||
|
|
||
| // Use 'forwardPorts' to make a list of ports inside the container available locally. | ||
| "forwardPorts": [ | ||
mitchdenny marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| 15887, | ||
| 5180, | ||
| 7024, | ||
| 15551, | ||
| 33803, | ||
| 5350, | ||
| 41567, | ||
| 15306 | ||
| ], | ||
| "portsAttributes": { | ||
| "5180": { | ||
| "label": "WaitFor Playground: ApiService", | ||
| "protocol": "http" | ||
| }, | ||
| "5350": { | ||
| "label": "Redis Playground: Api Service" | ||
| }, | ||
| "7024": { | ||
| "label": "WaitFor Playground: Frontend", | ||
| "protocol": "https" | ||
| }, | ||
| "15306": { | ||
| "label": "Redis Playground: App Host" | ||
| }, | ||
| "15551": { | ||
| "label": "WaitFor Playground: PGAdmin", | ||
| "protocol": "http" | ||
| }, | ||
| "15887": { | ||
| "label": "WaitFor Playground: AppHost", | ||
| "protocol": "https" | ||
| }, | ||
| "33803": { | ||
| "label": "Redis Playground: Redis Commander" | ||
| }, | ||
| "41567": { | ||
| "label": "Redis Playground: Redis Insight" | ||
| } | ||
| }, | ||
| "otherPortsAttributes": { | ||
| "onAutoForward": "ignore" | ||
mitchdenny marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| }, | ||
|
|
||
| // Use 'postCreateCommand' to run commands after the container is created. | ||
| "customizations": { | ||
| "vscode": { | ||
| "extensions": [ | ||
| "ms-dotnettools.csdevkit", | ||
| "ms-azuretools.vscode-bicep", | ||
| "ms-azuretools.azure-dev" | ||
| ], | ||
| "settings": { | ||
| "remote.autoForwardPorts": false, | ||
mitchdenny marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| "dotnet.defaultSolution": "Aspire.sln" | ||
mitchdenny marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| } | ||
| } | ||
| }, | ||
| "onCreateCommand": "dotnet restore", | ||
| "postStartCommand": "dotnet dev-certs https --trust" | ||
mitchdenny marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| // Configure tool-specific properties. | ||
| // "customizations": {}, | ||
|
|
||
| // Uncomment to connect as root instead. More info: https://aka.ms/dev-containers-non-root. | ||
| // "remoteUser": "root" | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -6,6 +6,7 @@ | |
| using Aspire.Hosting.ApplicationModel; | ||
| using Aspire.Hosting.Postgres; | ||
| using Aspire.Hosting.Utils; | ||
| using Microsoft.Extensions.Configuration; | ||
| using Microsoft.Extensions.DependencyInjection; | ||
|
|
||
| namespace Aspire.Hosting; | ||
|
|
@@ -333,6 +334,16 @@ private static void SetPgAdminEnvironmentVariables(EnvironmentCallbackContext co | |
| // You need to define the PGADMIN_DEFAULT_EMAIL and PGADMIN_DEFAULT_PASSWORD or PGADMIN_DEFAULT_PASSWORD_FILE environment variables. | ||
| context.EnvironmentVariables.Add("PGADMIN_DEFAULT_EMAIL", "[email protected]"); | ||
| context.EnvironmentVariables.Add("PGADMIN_DEFAULT_PASSWORD", "admin"); | ||
|
|
||
| // When running in the context of Codespaces we need to set some additional environment | ||
| // varialbes so that PGAdmin will trust the forwarded headers that Codespaces port | ||
| // forwarding will send. | ||
| var config = context.ExecutionContext.ServiceProvider.GetRequiredService<IConfiguration>(); | ||
| if (context.ExecutionContext.IsRunMode && config.GetValue<bool>("CODESPACES", false)) | ||
| { | ||
| context.EnvironmentVariables["PGADMIN_CONFIG_PROXY_X_HOST_COUNT"] = "1"; | ||
| context.EnvironmentVariables["PGADMIN_CONFIG_PROXY_X_PREFIX_COUNT"] = "1"; | ||
| } | ||
| } | ||
|
|
||
| /// <summary> | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,66 @@ | ||
| // Licensed to the .NET Foundation under one or more agreements. | ||
| // The .NET Foundation licenses this file to you under the MIT license. | ||
|
|
||
| using System.Diagnostics.CodeAnalysis; | ||
| using Microsoft.Extensions.Configuration; | ||
| using Microsoft.Extensions.Options; | ||
|
|
||
| namespace Aspire.Hosting.Codespaces; | ||
|
|
||
| /// <summary> | ||
| /// GitHub Codespaces configuration values. | ||
| /// </summary> | ||
| internal class CodespacesOptions | ||
| { | ||
| /// <summary> | ||
| /// When set to true, the app host is running in a GitHub Codespace. | ||
| /// </summary> | ||
| /// <remarks> | ||
| /// Maps to the CODESPACE environment variable. | ||
| /// </remarks> | ||
| public bool IsCodespace { get; set; } | ||
|
|
||
| /// <summary> | ||
| /// When set it is the domain suffix used when port forwarding services hosted on the Codespace. | ||
| /// </summary> | ||
| /// <remarks> | ||
| /// Maps to the GITHUB_CODESPACES_PORT_FORWARDING_DOMAIN environment variable. | ||
| /// </remarks> | ||
| [MemberNotNullWhen(true, nameof(IsCodespace))] | ||
| public string? PortForwardingDomain { get; set; } | ||
|
|
||
| /// <summary> | ||
| /// When set it is the name of the GitHub Codespace in which the app host is running. | ||
| /// </summary> | ||
| /// <remarks> | ||
| /// Maps to the CODESPACE_NAME environment variable. | ||
| /// </remarks> | ||
| [MemberNotNullWhen(true, nameof(IsCodespace))] | ||
| public string? CodespaceName { get; set; } | ||
| } | ||
|
|
||
| internal class ConfigureCodespacesOptions(IConfiguration configuration) : IConfigureOptions<CodespacesOptions> | ||
| { | ||
| private const string CodespacesEnvironmentVariable = "CODESPACES"; | ||
| private const string CodespaceNameEnvironmentVariable = "CODESPACE_NAME"; | ||
| private const string GitHubCodespacesPortForwardingDomain = "GITHUB_CODESPACES_PORT_FORWARDING_DOMAIN"; | ||
|
|
||
| private string GetRequiredCodespacesConfigurationValue(string key) | ||
| { | ||
| ArgumentNullException.ThrowIfNullOrEmpty(key); | ||
| return configuration.GetValue<string>(key) ?? throw new DistributedApplicationException($"Codespaces was detected but {key} environment missing."); | ||
| } | ||
|
|
||
| public void Configure(CodespacesOptions options) | ||
| { | ||
| if (!configuration.GetValue<bool>(CodespacesEnvironmentVariable, false)) | ||
| { | ||
| options.IsCodespace = false; | ||
| return; | ||
| } | ||
|
|
||
| options.IsCodespace = true; | ||
| options.PortForwardingDomain = GetRequiredCodespacesConfigurationValue(GitHubCodespacesPortForwardingDomain); | ||
| options.CodespaceName = GetRequiredCodespacesConfigurationValue(CodespaceNameEnvironmentVariable); | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.