Skip to content

Add devcontainer configuration files #2870

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

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions .devcontainer/dev.Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# Base image: .NET SDK for building and running ASP.NET Core
FROM mcr.microsoft.com/devcontainers/dotnet:8.0-bookworm

# Install common dev tools
RUN apt-get update && apt-get install -y \
curl \
git \
unzip \
zip \
iproute2 \
dnsutils \
procps \
&& apt-get clean

# Install the .NET SDK for ASP.NET Core 10.0 (preview)
RUN curl -SL --output dotnet-install.sh https://dot.net/v1/dotnet-install.sh && \
bash dotnet-install.sh --version 10.0.100-preview.5.25265.106 --install-dir /usr/share/dotnet && \
rm dotnet-install.sh

# Install Node.js for Swagger UI builds or UI dashboards (optional)
RUN curl -fsSL https://deb.nodesource.com/setup_18.x | bash - && \
apt-get install -y nodejs
29 changes: 29 additions & 0 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
// 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
"dockerFile": "dev.Dockerfile",
// 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": [
5000,
5001
],
// Use 'postCreateCommand' to run commands after the container is created.
"postCreateCommand": "dotnet restore",
"customizations": {
"vscode": {
"extensions": [
"ms-dotnettools.csharp",
"patcx.vscode-nuget-gallery",
"fernandoescolar.vscode-solution-explorer"
]
}
},
// Configure tool-specific properties.
// "customizations": {},
// Uncomment to connect as root instead. More info: https://aka.ms/dev-containers-non-root.
// "remoteUser": "root"
}
114 changes: 114 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,114 @@
{
"version": "0.2.0",
"configurations": [
{
"name": ".NET BasicYarpSample (net8.0)",
"type": "coreclr",
"request": "launch",
"preLaunchTask": "build",
"program": "${workspaceFolder}/artifacts/bin/BasicYarpSample/Debug/net8.0/BasicYarpSample.dll",
"cwd": "${workspaceFolder}/samples/BasicYarpSample",
"stopAtEntry": false,
"console": "internalConsole"
},
{
"name": ".NET ReverseProxy.Auth.Sample (net8.0)",
"type": "coreclr",
"request": "launch",
"program": "${workspaceFolder}/artifacts/bin/ReverseProxy.Auth.Sample/Debug/net8.0/ReverseProxy.Auth.Sample.dll",
"cwd": "${workspaceFolder}/samples/ReverseProxy.Auth.Sample",
"stopAtEntry": false,
"console": "internalConsole"
},
{
"name": ".NET ReverseProxy.Code.Sample (net8.0)",
"type": "coreclr",
"request": "launch",
"program": "${workspaceFolder}/artifacts/bin/ReverseProxy.Code.Sample/Debug/net8.0/ReverseProxy.Code.Sample.dll",
"cwd": "${workspaceFolder}/samples/ReverseProxy.Code.Sample",
"stopAtEntry": false,
"console": "internalConsole"
},
{
"name": ".NET ReverseProxy.Config.Sample (net8.0)",
"type": "coreclr",
"request": "launch",
"program": "${workspaceFolder}/artifacts/bin/ReverseProxy.Config.Sample/Debug/net8.0/ReverseProxy.Config.Sample.dll",
"cwd": "${workspaceFolder}/samples/ReverseProxy.Config.Sample",
"stopAtEntry": false,
"console": "internalConsole"
},
{
"name": ".NET ReverseProxy.ConfigFilter.Sample (net8.0)",
"type": "coreclr",
"request": "launch",
"program": "${workspaceFolder}/artifacts/bin/ReverseProxy.ConfigFilter.Sample/Debug/net8.0/ReverseProxy.ConfigFilter.Sample.dll",
"cwd": "${workspaceFolder}/samples/ReverseProxy.ConfigFilter.Sample",
"stopAtEntry": false,
"console": "internalConsole"
},
{
"name": ".NET ReverseProxy.Direct.Sample (net8.0)",
"type": "coreclr",
"request": "launch",
"program": "${workspaceFolder}/artifacts/bin/ReverseProxy.Direct.Sample/Debug/net8.0/ReverseProxy.Direct.Sample.dll",
"cwd": "${workspaceFolder}/samples/ReverseProxy.Direct.Sample",
"stopAtEntry": false,
"console": "internalConsole"
},
{
"name": ".NET ReverseProxy.HttpSysDelegation.Sample (net8.0)",
"type": "coreclr",
"request": "launch",
"program": "${workspaceFolder}/artifacts/bin/ReverseProxy.HttpSysDelegation.Sample/Debug/net8.0/ReverseProxy.HttpSysDelegation.Sample.dll",
"cwd": "${workspaceFolder}/samples/ReverseProxy.HttpSysDelegation.Sample",
"stopAtEntry": false,
"console": "internalConsole"
},
{
"name": ".NET ReverseProxy.LetsEncrypt.Sample (net8.0)",
"type": "coreclr",
"request": "launch",
"program": "${workspaceFolder}/artifacts/bin/ReverseProxy.LetsEncrypt.Sample/Debug/net8.0/ReverseProxy.LetsEncrypt.Sample.dll",
"cwd": "${workspaceFolder}/samples/ReverseProxy.LetsEncrypt.Sample",
"stopAtEntry": false,
"console": "internalConsole"
},
{
"name": ".NET ReverseProxy.Metrics.Sample (net8.0)",
"type": "coreclr",
"request": "launch",
"program": "${workspaceFolder}/artifacts/bin/ReverseProxy.Metrics.Sample/Debug/net8.0/ReverseProxy.Metrics.Sample.dll",
"cwd": "${workspaceFolder}/samples/ReverseProxy.Metrics.Sample",
"stopAtEntry": false,
"console": "internalConsole"
},
{
"name": ".NET ReverseProxy.Metrics.Prometheus.Sample (net8.0)",
"type": "coreclr",
"request": "launch",
"program": "${workspaceFolder}/artifacts/bin/ReverseProxy.Metrics-Prometheus.Sample/Debug/net8.0/ReverseProxy.Metrics-Prometheus.Sample.dll",
"cwd": "${workspaceFolder}/samples/Prometheus/ReverseProxy.Metrics-Prometheus.Sample",
"stopAtEntry": false,
"console": "internalConsole"
},
{
"name": ".NET ReverseProxy.Transforms.Sample (net8.0)",
"type": "coreclr",
"request": "launch",
"program": "${workspaceFolder}/artifacts/bin/ReverseProxy.Transforms.Sample/Debug/net8.0/ReverseProxy.Transforms.Sample.dll",
"cwd": "${workspaceFolder}/samples/ReverseProxy.Transforms.Sample",
"stopAtEntry": false,
"console": "internalConsole"
},
{
"name": ".NET SampleServer (net8.0)",
"type": "coreclr",
"request": "launch",
"program": "${workspaceFolder}/artifacts/bin/SampleServer/Debug/net8.0/SampleServer.dll",
"cwd": "${workspaceFolder}/samples/SampleServer",
"stopAtEntry": false,
"console": "internalConsole"
}
]
}
21 changes: 21 additions & 0 deletions .vscode/tasks.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"version": "2.0.0",
"tasks": [
{
"label": "build",
"command": "dotnet",
"type": "shell",
"args": [
"build",
"${workspaceFolder}/samples/BasicYarpSample/BasicYarpSample.csproj",
"-c", "Debug",
"-f", "net8.0"
],
"group": {
"kind": "build",
"isDefault": true
},
"problemMatcher": ["$msCompile"]
}
]
}
16 changes: 16 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,22 @@ When you're done, you can run the `deactivate` function to undo the changes to y

If you're having trouble building the project, or developing in Visual Studio, please file an issue to let us know and we'll help out (and fix our scripts/tools as needed)!

## Using a devcontainer

YARP includes full support for [VS Code Dev Containers](https://code.visualstudio.com/docs/devcontainers/containers). This is the easiest way to get started on Linux, macOS, or Windows with Docker + VS Code.

To build and run YARP in a devcontainer:

1. **Open the repository in VS Code.**
2. If prompted, click **"Reopen in Container"**. If not prompted, open the Command Palette (`Ctrl+Shift+P`) and select **"Dev Containers: Reopen in Container"**.
3. Wait for the container to build and initialize. All required tools (including .NET SDK, Node.js, npm, Git, and ESLint) are pre-installed and available on the `PATH`.
4. Use the built-in VS Code tasks and launch configurations to build, test, and debug YARP:
- Press `Ctrl+Shift+B` to build the solution.
- Open the Run and Debug panel to launch and debug any sample or project.
- Use the integrated terminal for CLI commands like `dotnet build`, `dotnet test`, or `dotnet run`.

The devcontainer ensures a consistent, ready-to-use environment for YARP development across all platforms.

# Testing

The command to build and run all tests: `build.cmd/sh -test`.
Expand Down
Loading