Skip to content

Commit

Permalink
Continue to build cross-platform container image
Browse files Browse the repository at this point in the history
  • Loading branch information
dlipovetsky committed Sep 19, 2023
1 parent 32d6b3b commit b36b243
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 5 deletions.
4 changes: 0 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -87,10 +87,6 @@ golangci-lint: $(GOLANGCI_LINT) ## Run golangci-lint against code.
gosec: $(GOSEC) ## Run gosec against code.
$(GOSEC) -conf .gosec.json ./...

build-within-docker: vendor
mkdir -p /build/cluster-api-provider-cloud-director
CGO_ENABLED=0 go build -ldflags "-X github.com/vmware/$(CAPVCD_IMG)/version.Version=${VERSION}" -o /build/vcloud/cluster-api-provider-cloud-director main.go

.PHONY: shellcheck
shellcheck: $(SHELLCHECK) ## Run shellcheck against code.
find . -name '*.*sh' -not -path '*/vendor/*' | xargs $(SHELLCHECK) --color
Expand Down
32 changes: 32 additions & 0 deletions d2iq.Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# syntax=docker/dockerfile:1

# Build the manager binary
FROM golang:1.19 as builder

RUN apt-get update && \
apt-get -y install \
bash \
git \
make

ADD . /go/src/github.com/vmware/cluster-api-provider-cloud-director
WORKDIR /go/src/github.com/vmware/cluster-api-provider-cloud-director

ENV GOPATH /go
ENV GOARCH $TARGETARCH
ARG VERSION
RUN make -f d2iq.Makefile build-within-docker VERSION=$VERSION && \
chmod +x /build/vcloud/cluster-api-provider-cloud-director

########################################################

FROM scratch

WORKDIR /opt/vcloud/bin

COPY --from=builder /build/vcloud/cluster-api-provider-cloud-director .
COPY --from=builder /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/ca-certificates.crt

# nobody user ID
USER 65534
ENTRYPOINT ["/opt/vcloud/bin/cluster-api-provider-cloud-director"]
7 changes: 6 additions & 1 deletion d2iq.Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ push-capvcd-image: docker-buildx-builder generate fmt vet vendor
--output=type=registry \
--build-arg VERSION=$(VERSION) \
--tag $(REGISTRY)/$(CAPVCD_IMG):$(VERSION) \
--file Dockerfile \
--file d2iq.Dockerfile \
.

.PHONY: docker-buildx-builder
Expand All @@ -26,3 +26,8 @@ release-manifests: kustomize
mkdir -p $(MANIFEST_DIR)
cd config/manager && $(KUSTOMIZE) edit set image projects.registry.vmware.com/vmware-cloud-director/cluster-api-provider-cloud-director=$(REGISTRY)/$(CAPVCD_IMG):$(VERSION)
$(KUSTOMIZE) build config/default > $(MANIFEST_DIR)/infrastructure-components.yaml

.PHONY: build-within-docker
build-within-docker: vendor
mkdir -p /build/cluster-api-provider-cloud-director
CGO_ENABLED=0 go build -ldflags "-X github.com/vmware/$(CAPVCD_IMG)/version.Version=${VERSION}" -o /build/vcloud/cluster-api-provider-cloud-director main.go

0 comments on commit b36b243

Please sign in to comment.