Skip to content

Commit

Permalink
docker: reduce images size for client as well
Browse files Browse the repository at this point in the history
By introducing multi-stage build
And switching to alpine
And using grpcurl from docker

x10 size reduction !

```
$ docker images | grep opi
opi-storage-client                      main           cd27f72378fb   2 minutes ago       20.4MB
ghcr.io/opiproject/opi-storage-client   main           633e8f737c1a   18 hours ago        612MB

```

Signed-off-by: Boris Glimcher <Boris.Glimcher@emc.com>
  • Loading branch information
glimchb committed Jan 11, 2023
1 parent db64ed6 commit 3c1a538
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions client/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
# syntax=docker/dockerfile:1
# SPDX-License-Identifier: Apache-2.0
# Copyright (c) 2022 Dell Inc, or its subsidiaries.

# Alpine is chosen for its small footprint
# compared to Ubuntu
FROM docker.io/library/golang:1.19.5-alpine
FROM docker.io/library/golang:1.19.5-alpine as builder

WORKDIR /app

Expand All @@ -15,5 +14,8 @@ RUN go mod download
COPY *.go ./
RUN go build -v -o /opi-storage-client && CGO_ENABLED=0 go test -v ./...

# second stage to reduce image size
FROM alpine:3.17
COPY --from=builder /opi-storage-client /
EXPOSE 50051
CMD [ "/opi-storage-client" ]
CMD [ "/opi-storage-client"]

0 comments on commit 3c1a538

Please sign in to comment.