Building, shipping and running .NET apps in containers
Alistair Chapman
@agc93
Alistair Chapman
@agc93
Alistair Chapman
Â
agc93
Â
agc93
.NET MVP
Information Security Architect @ Red Hat
Walking, talking case of impostor syndrome
Â
Â
FROM microsoft/dotnet:2.0-sdk
COPY . /app
WORKDIR /app
RUN ["dotnet", "restore"]
RUN ["dotnet", "build"]
EXPOSE 5000/tcp
ENV ASPNETCORE_URLS="http://*:5000"
CMD ["dotnet", "run"]
FROM microsoft/dotnet:2.0-sdk AS build-env
COPY . /app
WORKDIR /app
RUN dotnet restore
RUN dotnet publish -c Release -o out
FROM microsoft/dotnet:2.0-runtime
WORKDIR /app
COPY --from=build-env /app/out .
EXPOSE 5000/tcp
ENV ASPNETCORE_URLS="http://*:5000"
CMD ["dotnet", "demo.dll"]
FROM microsoft/dotnet:2.0-sdk AS build-env
WORKDIR /app
# copy csproj and restore as distinct layers
COPY *.csproj ./
RUN dotnet restore
# copy everything else and build
COPY . ./
RUN dotnet publish -c Release -o out
# build runtime image
FROM microsoft/dotnet:2.0-runtime
WORKDIR /app
COPY --from=build-env /app/out ./
ENTRYPOINT ["dotnet", "dotnetapp.dll"]
FROM microsoft/dotnet:2.0-sdk AS build-env
WORKDIR /app
# copy csproj and restore as distinct layers
COPY *.csproj ./
RUN dotnet restore
# copy everything else and build
COPY . ./
RUN dotnet publish -c Release -r linux-x64 -o out
# build runtime image
FROM fedora:26
WORKDIR /app
RUN dnf install -y libicu libunwind
COPY --from=build-env /app/out ./
ENTRYPOINT ["./dotnetapp"]
You can use containers to:
Credit: Michael Ducy
@agc93
(essentially everywhere)
Â
Â
https://agchapman.com/talks
https://blog.agchapman.com/