Skip to content

Commit ab60166

Browse files
orthrosahmetb
authored andcommitted
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)
1 parent 3863f6d commit ab60166

File tree

2 files changed

+24
-11
lines changed

2 files changed

+24
-11
lines changed

src/cartservice/Dockerfile

Lines changed: 23 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,35 @@
1-
# cartservice_probe
2-
FROM golang:1.10 as builder
1+
FROM golang:1.10 as probe
32
RUN wget -qO/go/bin/dep https://github.com/golang/dep/releases/download/v0.5.0/dep-linux-amd64 && \
4-
chmod +x /go/bin/dep
3+
chmod +x /go/bin/dep
54
ENV PROJECT github.com/GoogleCloudPlatform/microservices-demo/src/cartservice/probe
65
WORKDIR /go/src/$PROJECT
76
COPY probe/Gopkg.* ./
87
RUN dep ensure --vendor-only -v
98
COPY ./probe ./
109
RUN go build -o /cartservice_probe .
1110

12-
# cartservice
13-
FROM gcr.io/google-appengine/aspnetcore:2.1.0
14-
COPY --from=builder /cartservice_probe /cartservice_probe
15-
RUN apt-get update && apt-get install net-tools telnet
11+
FROM microsoft/dotnet:2.1-sdk-alpine as builder
1612
WORKDIR /app
1713
COPY . .
1814
RUN dotnet restore && \
1915
dotnet build && \
20-
dotnet publish
21-
WORKDIR /app/bin/Debug/netcoreapp2.0
22-
ENTRYPOINT ["dotnet", "cartservice.dll", "start"]
16+
dotnet publish -c release -r linux-musl-x64 -o /cartservice
17+
18+
# cartservice
19+
FROM alpine:3.8
20+
# Add the probe
21+
COPY --from=probe /cartservice_probe /cartservice_probe
22+
# Dependencies for runtime
23+
# busybox-extras => telnet
24+
RUN apk add --no-cache \
25+
busybox-extras \
26+
libc6-compat \
27+
libunwind \
28+
libuuid \
29+
libgcc \
30+
libstdc++ \
31+
libintl \
32+
icu
33+
WORKDIR /app
34+
COPY --from=builder /cartservice .
35+
ENTRYPOINT ["./cartservice", "start"]

src/cartservice/cartservice.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
<PropertyGroup>
44
<OutputType>Exe</OutputType>
5-
<TargetFramework>netcoreapp2.0</TargetFramework>
5+
<TargetFramework>netcoreapp2.1</TargetFramework>
66
</PropertyGroup>
77

88
<ItemGroup>

0 commit comments

Comments
 (0)