diff --git a/.devcontainer/dev.Dockerfile b/.devcontainer/dev.Dockerfile new file mode 100644 index 000000000..aaf707425 --- /dev/null +++ b/.devcontainer/dev.Dockerfile @@ -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 \ No newline at end of file diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json new file mode 100644 index 000000000..5c1bed3a0 --- /dev/null +++ b/.devcontainer/devcontainer.json @@ -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" +} \ No newline at end of file diff --git a/.vscode/launch.json b/.vscode/launch.json new file mode 100644 index 000000000..85b99e6dd --- /dev/null +++ b/.vscode/launch.json @@ -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" + } + ] +} diff --git a/.vscode/tasks.json b/.vscode/tasks.json new file mode 100644 index 000000000..59fa2b3e0 --- /dev/null +++ b/.vscode/tasks.json @@ -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"] + } + ] +} diff --git a/README.md b/README.md index 1cd4a2c86..06fd40e5a 100644 --- a/README.md +++ b/README.md @@ -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`.