yarp Docker & Self-Hosted Deployment

GitHub

A toolkit for developing high-performance HTTP reverse proxy applications.

9,493 stars C# C# 1 file ยท ~15,589 tokens
1. Pull Image (DOCKERHUB) docker pull dotnet/yarp:latest
2. Docker Run (1-Click Launch) docker run -d --name yarp -p 80:80 --restart always dotnet/yarp:latest
3. Podman Run podman run -d --name yarp -p 80:80 --restart always dotnet/yarp:latest
4. Skopeo Inspect (Zero-Pull Manifest) skopeo inspect docker://docker.io/dotnet/yarp:latest
5. ORAS Pull (OCI Artifact) oras pull dotnet/yarp:latest
samples/KubernetesIngress.Sample/Monitor/Dockerfile
#See https://aka.ms/containerfastmode to understand how Visual Studio uses this Dockerfile to build your images for faster debugging.

FROM mcr.microsoft.com/dotnet/aspnet:8.0 AS base
WORKDIR /app
EXPOSE 80
EXPOSE 443

FROM mcr.microsoft.com/dotnet/sdk:8.0  AS publish
WORKDIR /src
# We need to install the SDK manually because we might target an unreleased SDK
COPY ["global.json", ""]
RUN curl -sSL https://dot.net/v1/dotnet-install.sh | bash /dev/stdin --jsonfile global.json
ENV DOTNET_SYSTEM_GLOBALIZATION_INVARIANT 1

# Copy csproj files and other files needed for restoring (to build a nuget cache layer to speed up rebuilds)
COPY ["samples/KubernetesIngress.Sample/Monitor/Yarp.Kubernetes.Monitor.csproj", "samples/KubernetesIngress.Sample/Monitor/"]
COPY ["src/ReverseProxy/Yarp.ReverseProxy.csproj", "src/ReverseProxy/"]
COPY ["src/Kubernetes.Controller/Yarp.Kubernetes.Controller.csproj", "src/Kubernetes.Controller/"]
COPY ["src/Directory.Build.props", "src/"]
COPY ["Directory.Build.*", "./"]
COPY ["TFMs.props", ""]
COPY ["NuGet.config", ""]
COPY ["eng/Versions.props", "eng/"]

# Build a cache layer with all of the nuget packages
RUN /root/.dotnet/dotnet restore samples/KubernetesIngress.Sample/Monitor/Yarp.Kubernetes.Monitor.csproj

# Copy the remaining source files
WORKDIR /src
COPY . .

WORKDIR /src/samples/KubernetesIngress.Sample/Monitor/
RUN /root/.dotnet/dotnet publish -c Release --no-restore -o /app/publish -f net8.0

FROM base AS final
WORKDIR /app
COPY --from=publish /app/publish .
ENTRYPOINT ["dotnet", "Yarp.Kubernetes.Monitor.dll"]