Skip to content

Commit

Permalink
feat(docker-swarm): configure builds for arm64 (#471)
Browse files Browse the repository at this point in the history
  • Loading branch information
s4ke committed Aug 21, 2023
1 parent 631b117 commit 2b9c067
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 12 deletions.
4 changes: 3 additions & 1 deletion .github/workflows/publish_on_master.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,9 @@ jobs:
- name: "make docker plugin"
run: |
cd deploy/docker-swarm/pkg
make push PLUGIN_NAME=${{ github.repository_owner }}/hcloud-csi-driver PLUGIN_TAG=latest-swarm
make push PLUGIN_NAME=${{ github.repository_owner }}/hcloud-csi-driver PLUGIN_TAG=latest-swarm ARCH=amd64
make push PLUGIN_NAME=${{ github.repository_owner }}/hcloud-csi-driver PLUGIN_TAG=latest-swarm-amd64 ARCH=amd64
make push PLUGIN_NAME=${{ github.repository_owner }}/hcloud-csi-driver PLUGIN_TAG=latest-swarm-arm64 ARCH=arm64
- name: Run GoReleaser
uses: goreleaser/goreleaser-action@v4
Expand Down
4 changes: 3 additions & 1 deletion .github/workflows/publish_on_tag.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,9 @@ jobs:
- name: "make docker plugin"
run: |
cd deploy/docker-swarm/pkg
make push PLUGIN_NAME=${{ github.repository_owner }}/hcloud-csi-driver PLUGIN_TAG=$RELEASE_VERSION-swarm
make push PLUGIN_NAME=${{ github.repository_owner }}/hcloud-csi-driver PLUGIN_TAG=$RELEASE_VERSION-swarm ARCH=amd64
make push PLUGIN_NAME=${{ github.repository_owner }}/hcloud-csi-driver PLUGIN_TAG=$RELEASE_VERSION-swarm-amd64 ARCH=amd64
make push PLUGIN_NAME=${{ github.repository_owner }}/hcloud-csi-driver PLUGIN_TAG=$RELEASE_VERSION-swarm-arm64 ARCH=arm64
- name: Run GoReleaser
uses: goreleaser/goreleaser-action@v4
Expand Down
6 changes: 3 additions & 3 deletions deploy/docker-swarm/pkg/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
FROM golang:1.19 as builder
FROM --platform=$TARGETPLATFORM golang:1.19 as builder
WORKDIR /csi
ADD go.mod go.sum /csi/
RUN go mod download
ADD . /csi/
RUN ls -al
RUN GOOS=linux GOARCH=amd64 CGO_ENABLED=0 go build -o aio.bin github.com/hetznercloud/csi-driver/cmd/aio
RUN CGO_ENABLED=0 go build -o aio.bin github.com/hetznercloud/csi-driver/cmd/aio

FROM --platform=linux/amd64 alpine:3.15
FROM --platform=$TARGETPLATFORM alpine:3.15
RUN apk add --no-cache ca-certificates e2fsprogs xfsprogs blkid xfsprogs-extra e2fsprogs-extra btrfs-progs cryptsetup
ENV GOTRACEBACK=all
RUN mkdir -p /plugin
Expand Down
15 changes: 8 additions & 7 deletions deploy/docker-swarm/pkg/Makefile
Original file line number Diff line number Diff line change
@@ -1,19 +1,20 @@
PLUGIN_NAME = hetznercloud/hcloud-csi-driver
PLUGIN_TAG ?= $(shell git describe --tags --exact-match 2> /dev/null || echo dev)-swarm
PLUGIN_TAG ?= $(shell git describe --tags --exact-match 2> /dev/null || echo dev)-swarm-${ARCH}
ARCH = amd64

all: create

clean:
@rm -rf ./plugin
@docker container rm -vf tmp_plugin_build || true
@docker container rm -vf tmp_plugin_build_${ARCH} || true

rootfs: clean
docker image build -f Dockerfile -t ${PLUGIN_NAME}:rootfs ../../../
docker image build --platform=linux/${ARCH} -f Dockerfile -t ${PLUGIN_NAME}:rootfs-${ARCH} ../../../
mkdir -p ./plugin/rootfs
docker container create --name tmp_plugin_build ${PLUGIN_NAME}:rootfs
docker container export tmp_plugin_build | tar -x -C ./plugin/rootfs
docker container create --name tmp_plugin_build_${ARCH} ${PLUGIN_NAME}:rootfs-${ARCH}
docker container export tmp_plugin_build_${ARCH} | tar -x -C ./plugin/rootfs
cp config.json ./plugin/
docker container rm -vf tmp_plugin_build
docker container rm -vf tmp_plugin_build_${ARCH}

create: rootfs
docker plugin rm -f ${PLUGIN_NAME}:${PLUGIN_TAG} 2> /dev/null || true
Expand All @@ -26,6 +27,6 @@ push: create
docker plugin push ${PLUGIN_NAME}:${PLUGIN_TAG}

push_latest: create
docker plugin push ${PLUGIN_NAME}:latest-swarm
docker plugin push ${PLUGIN_NAME}:latest-swarm-${ARCH}

.PHONY: clean rootfs create enable push

0 comments on commit 2b9c067

Please sign in to comment.