Skip to content

Commit

Permalink
Merge pull request #26 from Azuki-bar/arm-image
Browse files Browse the repository at this point in the history
add workflow to build and publish arm64 container image and binary
  • Loading branch information
fujiwara committed Jun 7, 2023
2 parents 0758c06 + 36f3617 commit beba39f
Show file tree
Hide file tree
Showing 6 changed files with 42 additions and 7 deletions.
9 changes: 7 additions & 2 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,16 @@ jobs:
make dist
make release
- name: Set up QEMU
uses: docker/setup-qemu-action@v2

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2

- name: docker
run: |
export TAG=$(echo $GITHUB_REF | cut -d/ -f3)
echo $DOCKER_TOKEN | docker login -u fujiwara --password-stdin
make docker-build-all
make docker-push-all
make docker-build-push-all
env:
DOCKER_TOKEN: ${{ secrets.DOCKER_TOKEN }}
12 changes: 11 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ lint: setup
golint -set_exit_status ./...

dist: setup
CGO_ENABLED=0 goxz -pv=$(LATEST_TAG) -os=darwin,linux -build-ldflags="-w -s" -arch=amd64 -d=dist -z ./cmd/maprobe
CGO_ENABLED=0 goxz -pv=$(LATEST_TAG) -os=darwin,linux -build-ldflags="-w -s" -arch=amd64,arm64 -d=dist -z ./cmd/maprobe

clean:
rm -fr dist/* test/config.*.yaml cmd/maprobe/maprobe
Expand All @@ -48,3 +48,13 @@ docker-push/%:
docker push fujiwara/maprobe:${TAG}-$*

docker-push-all: docker-push/bullseye-slim docker-push/buster-slim docker-push/mackerel-plugins docker-push/plain

docker-build-push/%:
docker buildx build --build-arg version=${TAG} \
--platform=linux/amd64,linux/arm64 \
-t maprobe:${TAG}-$* \
-f docker/$*/Dockerfile \
--push \
.

docker-build-push-all: docker-build-push/bullseye-slim docker-build-push/buster-slim docker-build-push/mackerel-plugins docker-build-push/plain
7 changes: 6 additions & 1 deletion docker/bullseye-slim/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
FROM golang:1.18.4-buster AS build-env
FROM --platform=${BUILDPLATFORM} golang:1.18.4-buster AS build-env

ARG TARGETOS
ARG TARGETARCH

ENV GOOS=${TARGETOS}
ENV GOARCH=${TARGETARCH}
ENV CGO_ENABLED=0
ENV GO111MODULE=on
RUN mkdir -p /go/src/github.com/fujiwara/maprobe
Expand Down
7 changes: 6 additions & 1 deletion docker/buster-slim/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
FROM golang:1.18.4-buster AS build-env
FROM --platform=${BUILDPLATFORM} golang:1.18.4-buster AS build-env

ARG TARGETOS
ARG TARGETARCH

ENV GOOS=${TARGETOS}
ENV GOARCH=${TARGETARCH}
ENV CGO_ENABLED=0
ENV GO111MODULE=on
RUN mkdir -p /go/src/github.com/fujiwara/maprobe
Expand Down
7 changes: 6 additions & 1 deletion docker/mackerel-plugins/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
FROM golang:1.18.4-buster AS build-env
FROM --platform=${BUILDPLATFORM} golang:1.18.4-buster AS build-env

ARG TARGETOS
ARG TARGETARCH

ENV GOOS=${TARGETOS}
ENV GOARCH=${TARGETARCH}
ENV CGO_ENABLED=0
ENV GO111MODULE=on
RUN apt-get update && apt-get -y install sudo
Expand Down
7 changes: 6 additions & 1 deletion docker/plain/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
FROM golang:1.18.4-buster AS build-env
FROM --platform=${BUILDPLATFORM} golang:1.18.4-buster AS build-env

ARG TARGETOS
ARG TARGETARCH

ENV GOOS=${TARGETOS}
ENV GOARCH=${TARGETARCH}
ENV CGO_ENABLED=0
ENV GO111MODULE=on
RUN mkdir -p /go/src/github.com/fujiwara/maprobe
Expand Down

0 comments on commit beba39f

Please sign in to comment.