Skip to content

Commit

Permalink
docker: reduce images size
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-server                      main           44996bc55718   About a minute ago   50.7MB
ghcr.io/opiproject/opi-storage-server   main           ae1f6b66da01   18 hours ago         618MB

```

Signed-off-by: Boris Glimcher <[email protected]>
  • Loading branch information
glimchb committed Jan 11, 2023
1 parent ea76149 commit db64ed6
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions server/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,10 @@ RUN go mod download
COPY *.go ./
RUN go build -v -o /opi-spdk-bridge && CGO_ENABLED=0 go test -v ./...

# second stage to reduce image size
FROM alpine:3.17
COPY --from=builder /opi-spdk-bridge /
COPY --from=docker.io/fullstorydev/grpcurl:v1.8.7-alpine /bin/grpcurl /usr/local/bin/
EXPOSE 50051
CMD [ "/opi-spdk-bridge" ]
CMD [ "/opi-spdk-bridge", "-port=50051" ]
HEALTHCHECK CMD grpcurl -plaintext localhost:50051 list || exit 1

0 comments on commit db64ed6

Please sign in to comment.