Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docker: reduce images size #94

Merged
merged 3 commits into from
Jan 11, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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"]
5 changes: 4 additions & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -59,14 +59,17 @@ services:
spdk:
condition: service_healthy
command: /opi-spdk-bridge -port=50051
healthcheck:
test: grpcurl -plaintext localhost:50051 list || exit 1

opi-spdk-client:
build:
context: client
networks:
- opi
depends_on:
- opi-spdk-server
opi-spdk-server:
condition: service_healthy
command: /opi-storage-client -addr=opi-spdk-server:50051

networks:
Expand Down
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