In cartservice, bumped .NET Target Framework to 2.1, optimized Dockerfile to reduce image size

This commit is contained in:
Colin Nelson 2018-09-21 15:25:52 -07:00
parent e56748f2d8
commit 1d60bc0314
2 changed files with 24 additions and 11 deletions

View file

@ -1,7 +1,6 @@
# cartservice_probe
FROM golang:1.10 as builder
FROM golang:1.10 as probe
RUN wget -qO/go/bin/dep https://github.com/golang/dep/releases/download/v0.5.0/dep-linux-amd64 && \
chmod +x /go/bin/dep
chmod +x /go/bin/dep
ENV PROJECT github.com/GoogleCloudPlatform/microservices-demo/src/cartservice/probe
WORKDIR /go/src/$PROJECT
COPY probe/Gopkg.* ./
@ -9,14 +8,28 @@ RUN dep ensure --vendor-only -v
COPY ./probe ./
RUN go build -o /cartservice_probe .
# cartservice
FROM gcr.io/google-appengine/aspnetcore:2.1.0
COPY --from=builder /cartservice_probe /cartservice_probe
RUN apt-get update && apt-get install net-tools telnet
FROM microsoft/dotnet:2.1-sdk-alpine as builder
WORKDIR /app
COPY . .
RUN dotnet restore && \
dotnet build && \
dotnet publish
WORKDIR /app/bin/Debug/netcoreapp2.0
ENTRYPOINT ["dotnet", "cartservice.dll", "start"]
dotnet publish -c release -r linux-musl-x64 -o /cartservice
# cartservice
FROM alpine:latest
# Add the probe
COPY --from=probe /cartservice_probe /cartservice_probe
# Dependencies for runtime
# busybox-extras => telnet
RUN apk add --no-cache \
busybox-extras \
libc6-compat \
libunwind \
libuuid \
libgcc \
libstdc++ \
libintl \
icu
WORKDIR /app
COPY --from=builder /cartservice .
ENTRYPOINT ["./cartservice", "start"]

View file

@ -2,7 +2,7 @@
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>netcoreapp2.0</TargetFramework>
<TargetFramework>netcoreapp2.1</TargetFramework>
</PropertyGroup>
<ItemGroup>