Reduced cartservice Docker Image size (#46)
Reduces docker image size for cartservice from ~2.36 GB to ~157 MB Fixes Issue #36 ![image-size](https://user-images.githubusercontent.com/7820716/45908973-37a31e00-bdb4-11e8-92d3-d84acfb1c10f.png)
This commit is contained in:
parent
3863f6d14d
commit
ab601665d1
2 changed files with 24 additions and 11 deletions
|
@ -1,5 +1,4 @@
|
||||||
# cartservice_probe
|
FROM golang:1.10 as probe
|
||||||
FROM golang:1.10 as builder
|
|
||||||
RUN wget -qO/go/bin/dep https://github.com/golang/dep/releases/download/v0.5.0/dep-linux-amd64 && \
|
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
|
ENV PROJECT github.com/GoogleCloudPlatform/microservices-demo/src/cartservice/probe
|
||||||
|
@ -9,14 +8,28 @@ RUN dep ensure --vendor-only -v
|
||||||
COPY ./probe ./
|
COPY ./probe ./
|
||||||
RUN go build -o /cartservice_probe .
|
RUN go build -o /cartservice_probe .
|
||||||
|
|
||||||
# cartservice
|
FROM microsoft/dotnet:2.1-sdk-alpine as builder
|
||||||
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
|
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
COPY . .
|
COPY . .
|
||||||
RUN dotnet restore && \
|
RUN dotnet restore && \
|
||||||
dotnet build && \
|
dotnet build && \
|
||||||
dotnet publish
|
dotnet publish -c release -r linux-musl-x64 -o /cartservice
|
||||||
WORKDIR /app/bin/Debug/netcoreapp2.0
|
|
||||||
ENTRYPOINT ["dotnet", "cartservice.dll", "start"]
|
# cartservice
|
||||||
|
FROM alpine:3.8
|
||||||
|
# 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"]
|
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<OutputType>Exe</OutputType>
|
<OutputType>Exe</OutputType>
|
||||||
<TargetFramework>netcoreapp2.0</TargetFramework>
|
<TargetFramework>netcoreapp2.1</TargetFramework>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
|
Loading…
Reference in a new issue