Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

multiarch container image build #140

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion .github/workflows/build-and-publish.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,10 @@ jobs:

- name: Build binary
run: |
make binary-remote
make binary-remote-amd64
make binary-remote-s390x
make binary-remote-ppc64le
make binary-remote-arm64

- name: Get image tags
id: image_tag
Expand All @@ -48,6 +51,7 @@ jobs:
with:
image: ${{ env.IMAGE_NAMESPACE }}
tags: "${{ steps.image_tag.outputs.IMAGE_TAG }}"
platforms: linux/amd64,linux/s390x,linux/ppc64le,linux/arm64
containerfiles: |
./Containerfile

Expand Down
12 changes: 7 additions & 5 deletions Containerfile
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
ARG ARCH="amd64"
ARG OS="linux"
FROM quay.io/prometheus/busybox-${OS}-${ARCH}:latest

FROM --platform=${BUILDPLATFORM:-linux/amd64} quay.io/prometheus/busybox:latest
LABEL maintainer="Navid Yaghoobi <[email protected]>"

COPY ./bin/remote/prometheus-podman-exporter /bin/podman_exporter
ARG TARGETPLATFORM
ARG BUILDPLATFORM
ARG TARGETOS
ARG TARGETARCH

COPY ./bin/remote/prometheus-podman-exporter-${TARGETARCH} /bin/podman_exporter

EXPOSE 9882
USER nobody
Expand Down
22 changes: 22 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,29 @@ binary-remote: ## Build prometheus-podman-exporter for remote connection
@mkdir -p $(BIN)/remote
@export CGO_ENABLED=0 && $(GO) build $(BUILDFLAGS) --tags "remote containers_image_openpgp" -ldflags="-X '$(PKG_PATH)/cmd.buildVersion=$(VERSION)' -X '$(PKG_PATH)/cmd.buildRevision=$(REVISION)' -X '$(PKG_PATH)/cmd.buildBranch=$(BRANCH)'" -o $(BIN)/remote/$(TARGET)

.PHONY: binary-remote-amd64
binary-remote-amd64: ## Build amd64 prometheus-podman-exporter for remote connection
@mkdir -p $(BIN)/remote
@echo "building amd64"
@export CGO_ENABLED=0 && GOARCH=amd64 $(GO) build $(BUILDFLAGS) --tags "remote containers_image_openpgp" -ldflags="-X '$(PKG_PATH)/cmd.buildVersion=$(VERSION)' -X '$(PKG_PATH)/cmd.buildRevision=$(REVISION)' -X '$(PKG_PATH)/cmd.buildBranch=$(BRANCH)'" -o $(BIN)/remote/$(TARGET)-amd64

.PHONY: binary-remote-s390x
binary-remote-s390x: ## Build s390x prometheus-podman-exporter for remote connection
@mkdir -p $(BIN)/remote
@echo "building s390x"
@export CGO_ENABLED=0 && GOARCH=s390x $(GO) build $(BUILDFLAGS) --tags "remote containers_image_openpgp" -ldflags="-X '$(PKG_PATH)/cmd.buildVersion=$(VERSION)' -X '$(PKG_PATH)/cmd.buildRevision=$(REVISION)' -X '$(PKG_PATH)/cmd.buildBranch=$(BRANCH)'" -o $(BIN)/remote/$(TARGET)-s390x

.PHONY: binary-remote-ppc64le
binary-remote-ppc64le: ## Build ppc64le prometheus-podman-exporter for remote connection
@mkdir -p $(BIN)/remote
@echo "building ppc64le"
@export CGO_ENABLED=0 && GOARCH=ppc64le $(GO) build $(BUILDFLAGS) --tags "remote containers_image_openpgp" -ldflags="-X '$(PKG_PATH)/cmd.buildVersion=$(VERSION)' -X '$(PKG_PATH)/cmd.buildRevision=$(REVISION)' -X '$(PKG_PATH)/cmd.buildBranch=$(BRANCH)'" -o $(BIN)/remote/$(TARGET)-ppc64le

.PHONY: binary-remote-arm64
binary-remote-arm64: ## Build arm64 prometheus-podman-exporter for remote connection
@mkdir -p $(BIN)/remote
@echo "building arm64"
@export CGO_ENABLED=0 && GOARCH=arm64 $(GO) build $(BUILDFLAGS) --tags "remote containers_image_openpgp" -ldflags="-X '$(PKG_PATH)/cmd.buildVersion=$(VERSION)' -X '$(PKG_PATH)/cmd.buildRevision=$(REVISION)' -X '$(PKG_PATH)/cmd.buildBranch=$(BRANCH)'" -o $(BIN)/remote/$(TARGET)-arm64

.PHONY: $(TARGET)
$(TARGET): $(SRC)
Expand Down