Skip to content
Merged
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
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Dockerfile
README.md
**/obj/
**/bin/
**/bin/
22 changes: 15 additions & 7 deletions docs/serving/samples/hello-world/helloworld-csharp/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,18 +1,26 @@
# Use Microsoft's official .NET image.
# https://hub.docker.com/r/microsoft/dotnet
FROM microsoft/dotnet:2.2-sdk
# Use Microsoft's official build .NET image.
# https://hub.docker.com/_/microsoft-dotnet-core-sdk/
FROM mcr.microsoft.com/dotnet/core/sdk:2.2 AS build
WORKDIR /app

# Install production dependencies.
# Copy csproj and restore as distinct layers.
WORKDIR /app
COPY *.csproj .
COPY *.csproj ./
RUN dotnet restore

# Copy local code to the container image.
COPY . .
COPY . ./
WORKDIR /app

# Build a release artifact.
RUN dotnet publish -c Release -o out


# Use Microsoft's official runtime .NET image.
# https://hub.docker.com/_/microsoft-dotnet-core-aspnet/
FROM mcr.microsoft.com/dotnet/core/aspnet:2.2 AS runtime
WORKDIR /app
COPY --from=build /app/out ./

# Run the web service on container startup.
CMD ["dotnet", "out/helloworld-csharp.dll"]
ENTRYPOINT ["dotnet", "helloworld-csharp.dll"]
34 changes: 21 additions & 13 deletions docs/serving/samples/hello-world/helloworld-csharp/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,29 +69,37 @@ cd knative-docs/docs/serving/samples/hello-world/helloworld-csharp
```

1. In your project directory, create a file named `Dockerfile` and copy the code
block below into it. For detailed instructions on dockerizing a .NET core
block below into it. For detailed instructions on dockerizing an ASP.NET Core
app, see
[dockerizing a .NET core app](https://docs.microsoft.com/en-us/dotnet/core/docker/docker-basics-dotnet-core#dockerize-the-net-core-application).
[Docker images for ASP.NET Core](https://docs.microsoft.com/en-us/aspnet/core/host-and-deploy/docker/building-net-docker-images).

```docker
# Use Microsoft's official .NET image.
# https://hub.docker.com/r/microsoft/dotnet
FROM microsoft/dotnet:2.2-sdk

# Use Microsoft's official build .NET image.
# https://hub.docker.com/_/microsoft-dotnet-core-sdk/
FROM mcr.microsoft.com/dotnet/core/sdk:2.2 AS build
WORKDIR /app

# Install production dependencies.
# Copy csproj and restore as distinct layers.
WORKDIR /app
COPY *.csproj .
COPY *.csproj ./
RUN dotnet restore

# Copy local code to the container image.
COPY . .

COPY . ./
WORKDIR /app

# Build a release artifact.
RUN dotnet publish -c Release -o out



# Use Microsoft's official runtime .NET image.
# https://hub.docker.com/_/microsoft-dotnet-core-aspnet/
FROM mcr.microsoft.com/dotnet/core/aspnet:2.2 AS runtime
WORKDIR /app
COPY --from=build /app/out ./

# Run the web service on container startup.
CMD ["dotnet", "out/helloworld-csharp.dll"]
ENTRYPOINT ["dotnet", "helloworld-csharp.dll"]
```

1. Create a `.dockerignore` file to ensure that any files related to a local
Expand Down