Skip to content

Commit a2df0e2

Browse files
Rakshith-Rmergify[bot]
authored andcommitted
build: add Containfile.sidecar and Makefile build cmds
Signed-off-by: Rakshith R <rar@redhat.com>
1 parent 7627f5c commit a2df0e2

File tree

2 files changed

+36
-0
lines changed

2 files changed

+36
-0
lines changed

Makefile

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11

22
# Image URL to use all building/pushing image targets
33
IMG ?= controller:latest
4+
SIDECAR_IMG ?= quay.io/csiaddons/k8s-sidecar
5+
TAG?= latest
46
# ENVTEST_K8S_VERSION refers to the version of kubebuilder assets to be downloaded by envtest binary.
57
ENVTEST_K8S_VERSION = 1.23
68

@@ -77,6 +79,14 @@ docker-build: test ## Build docker image with the manager.
7779
docker-push: ## Push docker image with the manager.
7880
docker push ${IMG}
7981

82+
.PHONY: docker-build-sidecar
83+
docker-build-sidecar:
84+
docker build -f ./build/Containerfile.sidecar -t ${SIDECAR_IMG}:${TAG} .
85+
86+
.PHONY: docker-push-sidecar
87+
docker-push-sidecar:
88+
docker push ${SIDECAR_IMG}:${TAG}
89+
8090
##@ Deployment
8191

8292
ifndef ignore-not-found

build/Containerfile.sidecar

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
# Build the sidecar binary
2+
FROM golang:1.17 as builder
3+
4+
WORKDIR /workspace
5+
# Copy the Go Modules manifests
6+
COPY go.mod go.mod
7+
COPY go.sum go.sum
8+
# cache deps before building and copying source so that we don't need to re-download as much
9+
# and so that source changes don't invalidate our downloaded layer
10+
RUN go mod download
11+
12+
# Copy the go source
13+
COPY sidecar/ sidecar/
14+
COPY api/ api/
15+
COPY internal/ internal/
16+
17+
# Build
18+
RUN CGO_ENABLED=0 GOOS=linux go build -a -o csi-addons-sidecar sidecar/main.go
19+
20+
# Use distroless as minimal base image to package the sidecar binary
21+
# Refer to https://github.com/GoogleContainerTools/distroless for more details
22+
FROM gcr.io/distroless/static:latest
23+
WORKDIR /
24+
COPY --from=builder /workspace/csi-addons-sidecar /usr/bin/
25+
26+
ENTRYPOINT ["/usr/bin/csi-addons-sidecar"]

0 commit comments

Comments
 (0)