Skip to content

Commit

Permalink
[docker] We don't need to copy ca certs anymore.
Browse files Browse the repository at this point in the history
  • Loading branch information
manugarg committed Feb 2, 2023
1 parent 2167666 commit d1b4071
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 14 deletions.
13 changes: 4 additions & 9 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -8,21 +8,16 @@
# This stage is used to find the correct binary for the platform. We store the
# correct binary at /stage-0-workdir/cloudprober, and in the next stage discard
# the rest.
FROM alpine AS stage0
WORKDIR /stage-0-workdir
FROM alpine
COPY cloudprober-linux-* ./

ARG TARGETPLATFORM
RUN if [ "$TARGETPLATFORM" = "linux/amd64" ]; then \
mv cloudprober-linux-amd64 cloudprober; fi
mv cloudprober-linux-amd64 cloudprober && rm cloudprober-linux-*; fi
RUN if [ "$TARGETPLATFORM" = "linux/arm64" ]; then \
mv cloudprober-linux-arm64 cloudprober; fi
mv cloudprober-linux-arm64 cloudprober && rm cloudprober-linux-*; fi
RUN if [ "$TARGETPLATFORM" = "linux/arm/v7" ]; then \
mv cloudprober-linux-armv7 cloudprober; fi

FROM alpine
COPY ca-certificates.crt /etc/ssl/certs/ca-certificates.crt
COPY --from=stage0 /stage-0-workdir/cloudprober /
mv cloudprober-linux-armv7 cloudprober && rm cloudprober-linux-*; fi

# Metadata params
ARG BUILD_DATE
Expand Down
6 changes: 1 addition & 5 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ GIT_COMMIT = $(strip $(shell git rev-parse --short HEAD))
GOBIN ?= ${GOPATH}/bin
BINARY ?= cloudprober
DOCKER_IMAGE ?= cloudprober/cloudprober
CACERTS ?= /etc/ssl/certs/ca-certificates.crt
SOURCES := $(shell find . -name '*.go')
LDFLAGS ?= "-s -w -X main.version=$(VERSION) -X main.buildTimestamp=$(BUILD_DATE) -X main.dirty=$(DIRTY) -extldflags -static"
BINARY_SOURCE ?= "./cmd/cloudprober.go"
Expand Down Expand Up @@ -37,10 +36,7 @@ $(foreach bin,$(BINARIES),$(eval $(call make-binary-target,$(bin))))
$(BINARY): $(SOURCES)
CGO_ENABLED=0 go build -o $@ -ldflags $(LDFLAGS) $(BINARY_SOURCE)

ca-certificates.crt: $(CACERTS)
cp $(CACERTS) ca-certificates.crt

docker_multiarch: $(addprefix cloudprober-, $(LINUX_PLATFORMS)) ca-certificates.crt Dockerfile
docker_multiarch: $(addprefix cloudprober-, $(LINUX_PLATFORMS)) Dockerfile
docker buildx build --push \
--build-arg BUILD_DATE=`date -u +"%Y-%m-%dT%H:%M:%SZ"` \
--build-arg VERSION=$(VERSION) \
Expand Down

0 comments on commit d1b4071

Please sign in to comment.