mirror of https://github.com/knative/docs.git
serving/samples/helloworld-csharp: simplify and standardize Dockerfile (#500)
This commit is contained in:
parent
165e2b279f
commit
772040a3f6
|
@ -1,14 +1,22 @@
|
|||
# Use Microsoft's official .NET image.
|
||||
# https://hub.docker.com/r/microsoft/dotnet
|
||||
FROM microsoft/dotnet:2.1-sdk
|
||||
WORKDIR /app
|
||||
|
||||
# copy csproj and restore as distinct layers
|
||||
COPY *.csproj ./
|
||||
# Install production dependencies.
|
||||
# Copy csproj and restore as distinct layers.
|
||||
WORKDIR /app
|
||||
COPY *.csproj .
|
||||
RUN dotnet restore
|
||||
|
||||
# copy and build everything else
|
||||
COPY . ./
|
||||
# Copy local code to the container image.
|
||||
COPY . .
|
||||
|
||||
# Build a release artifact.
|
||||
RUN dotnet publish -c Release -o out
|
||||
|
||||
EXPOSE 8080
|
||||
# Configure and document the service HTTP port.
|
||||
ENV PORT 8080
|
||||
EXPOSE $PORT
|
||||
|
||||
ENTRYPOINT ["dotnet", "out/helloworld-csharp.dll"]
|
||||
# Run the web service on container startup.
|
||||
CMD ["dotnet", "out/helloworld-csharp.dll"]
|
||||
|
|
|
@ -55,17 +55,28 @@ recreate the source files from this folder.
|
|||
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
|
||||
# Use Microsoft's official .NET image.
|
||||
# https://hub.docker.com/r/microsoft/dotnet
|
||||
FROM microsoft/dotnet:2.1-sdk
|
||||
WORKDIR /app
|
||||
|
||||
# copy csproj and restore as distinct layers
|
||||
COPY *.csproj ./
|
||||
# Install production dependencies.
|
||||
# Copy csproj and restore as distinct layers.
|
||||
WORKDIR /app
|
||||
COPY *.csproj .
|
||||
RUN dotnet restore
|
||||
|
||||
# copy and build everything else
|
||||
COPY . ./
|
||||
# Copy local code to the container image.
|
||||
COPY . .
|
||||
|
||||
# Build a release artifact.
|
||||
RUN dotnet publish -c Release -o out
|
||||
ENTRYPOINT ["dotnet", "out/helloworld-csharp.dll"]
|
||||
|
||||
# Configure and document the service HTTP port.
|
||||
ENV PORT 8080
|
||||
EXPOSE $PORT
|
||||
|
||||
# Run the web service on container startup.
|
||||
CMD ["dotnet", "out/helloworld-csharp.dll"]
|
||||
```
|
||||
|
||||
1. Create a new file, `service.yaml` and copy the following service definition
|
||||
|
|
Loading…
Reference in New Issue