Skip to content

Commit

Permalink
Multistage docker build for powerstore (#70)
Browse files Browse the repository at this point in the history
  • Loading branch information
panigs7 authored Jan 22, 2024
1 parent aae3aa7 commit f292e9d
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 5 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
vendor/
cmd/*/bin/

csm-common.mk
2 changes: 1 addition & 1 deletion .golangci.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
run:
timeout: 20m
issue-exit-code: 0 # we will change this later
issues-exit-code: 0 # we will change this later
tests: true
skip-dirs-use-default: true
modules-download-mode: readonly
Expand Down
20 changes: 18 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,12 +1,28 @@
ARG BASEIMAGE

# Build the sdk binary
FROM golang:1.21 as builder

# Set envirment variable
ENV APP_NAME csm-metrics-powerstore
ENV CMD_PATH cmd/metrics-powerstore/main.go

# Copy application data into image
COPY . /go/src/$APP_NAME
WORKDIR /go/src/$APP_NAME

# Build the binary
RUN go install github.com/golang/mock/[email protected]
RUN go generate ./...
RUN CGO_ENABLED=0 GOOS=linux go build -o /go/src/service /go/src/$APP_NAME/$CMD_PATH

# Build the sdk image
FROM $BASEIMAGE as final
LABEL vendor="Dell Inc." \
name="csm-metrics-powerstore" \
summary="Dell Container Storage Modules (CSM) for Observability - Metrics for PowerStore" \
description="Provides insight into storage usage and performance as it relates to the CSI (Container Storage Interface) Driver for Dell PowerStore" \
version="2.0.0" \
license="Apache-2.0"
ARG SERVICE
COPY $SERVICE/bin/service /service
COPY --from=builder /go/src/service /
ENTRYPOINT ["/service"]
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ test:
.PHONY: docker
docker: download-csm-common
$(eval include csm-common.mk)
SERVICE=cmd/metrics-powerstore docker build -t csm-metrics-powerstore -f Dockerfile --build-arg BASEIMAGE=$(DEFAULT_BASEIMAGE) cmd/metrics-powerstore/
docker build -t csm-metrics-powerstore -f Dockerfile --build-arg BASEIMAGE=$(DEFAULT_BASEIMAGE) .

.PHONY: push
push:
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ Once all prerequisites are on the Linux host, follow the steps below to clone an

1. Clone the repository using the following command: `git clone https://github.com/dell/csm-metrics-powerstore.git`
1. Set the DOCKER_REPO environment variable to point to the local Docker repository, for example: `export DOCKER_REPO=<ip-address>:<port>`
1. In the csm-metrics-powerstore directory, run the following command to build the Docker image called csm-metrics-powerstore: `make clean build docker`
1. In the csm-metrics-powerstore directory, run the following command to build the Docker image called csm-metrics-powerstore: `make docker`
1. Tag (with the "latest" tag) and push the image to the local Docker repository by running the following command: `make tag push`

__Note:__ Linux support only. If you are using a local insecure docker registry, ensure you configure the insecure registries on each of the Kubernetes worker nodes to allow access to the local docker repository.
Expand Down

0 comments on commit f292e9d

Please sign in to comment.