Skip to content

Commit

Permalink
WIP: tweaking with local builds
Browse files Browse the repository at this point in the history
Signed-off-by: Ashley Davis <[email protected]>
  • Loading branch information
SgtCoDFish committed Jan 2, 2024
1 parent 6a9f141 commit 7342a48
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 7 deletions.
10 changes: 7 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,10 @@
# limitations under the License.

# Build the trust binary
FROM docker.io/library/golang:1.21 as builder
FROM --platform=$BUILDPLATFORM docker.io/library/golang:1.21 as builder

ARG GOPROXY
ARG TARGETARCH

WORKDIR /workspace
# Copy the Go Modules manifests
Expand All @@ -34,13 +35,16 @@ COPY hack/ hack/
RUN GOPROXY=$GOPROXY go mod download

# Build
RUN make build
RUN make build-linux-$TARGETARCH

FROM scratch

ARG TARGETARCH

LABEL description="trust-manager is an operator for distributing trust bundles across a Kubernetes cluster"

WORKDIR /
USER 1001
COPY --from=builder /workspace/bin/trust-manager /usr/bin/trust-manager
COPY --from=builder /workspace/bin/trust-manager-linux-$TARGETARCH /usr/bin/trust-manager

ENTRYPOINT ["/usr/bin/trust-manager"]
8 changes: 7 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -98,9 +98,15 @@ vet:
.PHONY: build
build: $(BINDIR)/trust-manager | $(BINDIR) ## build trust-manager for the host system architecture

.PHONY: build-linux-amd64 build-linux-arm64 build-linux-ppc64le build-linux-arm
build-linux-amd64 build-linux-arm64 build-linux-ppc64le build-linux-arm: build-linux-%: $(BINDIR)/trust-manager-linux-%

$(BINDIR)/trust-manager: $(GO_SOURCES) | $(BINDIR)
CGO_ENABLED=0 go build -o $(BINDIR)/trust-manager ./cmd/trust-manager

$(BINDIR)/trust-manager-linux-amd64 $(BINDIR)/trust-manager-linux-arm64 $(BINDIR)/trust-manager-linux-ppc64le $(BINDIR)/trust-manager-linux-arm: $(BINDIR)/trust-manager-linux-%: $(GO_SOURCES) | $(BINDIR)
CGO_ENABLED=0 GOOS=linux GOARCH=$* go build -o $@ ./cmd/trust-manager

.PHONY: generate
generate: depend generate-deepcopy generate-applyconfigurations generate-manifests

Expand Down Expand Up @@ -140,7 +146,7 @@ ifeq ($(OS), linux)
endif
docker buildx rm $(BUILDX_BUILDER) &>/dev/null || :
./hack/wait-for-buildx.sh $(BUILDX_BUILDER) gone
docker buildx create --name $(BUILDX_BUILDER) --driver docker-container --use
docker buildx create --name $(BUILDX_BUILDER) --bootstrap --driver docker-container --platform $(IMAGE_PLATFORMS)
./hack/wait-for-buildx.sh $(BUILDX_BUILDER) exists
docker buildx inspect --bootstrap --builder $(BUILDX_BUILDER)

Expand Down
7 changes: 4 additions & 3 deletions trust-packages/debian/Containerfile
Original file line number Diff line number Diff line change
Expand Up @@ -12,19 +12,20 @@
# See the License for the specific language governing permissions and
# limitations under the License.

FROM docker.io/library/golang:1.21 as gobuild
FROM --platform=$BUILDPLATFORM docker.io/library/golang:1.21 as gobuild

ARG GOPROXY
ARG TARGETARCH

WORKDIR /work

COPY go.mod go.mod
COPY go.sum go.sum
COPY main.go main.go

RUN GOPROXY=$GOPROXY CGO_ENABLED=0 go build -o copyandmaybepause main.go
RUN GOPROXY=$GOPROXY CGO_ENABLED=0 GOARCH=$TARGETARCH go build -o copyandmaybepause main.go

RUN GOPROXY=$GOPROXY CGO_ENABLED=0 go install github.com/cert-manager/trust-manager/cmd/validate-trust-package@main
RUN GOPROXY=$GOPROXY go get github.com/cert-manager/trust-manager/cmd/validate-trust-package && GOPROXY=$GOPROXY CGO_ENABLED=0 GOARCH=$TARGETARCH go build -o /go/bin/validate-trust-package github.com/cert-manager/trust-manager/cmd/validate-trust-package

FROM docker.io/library/debian:11-slim as debbase

Expand Down

0 comments on commit 7342a48

Please sign in to comment.