Skip to content

Commit 1725daf

Browse files
authored
Merge pull request #397 from andyzhangx/arm64
chore: refactor Makefile
2 parents 5892f8b + 4958c49 commit 1725daf

File tree

3 files changed

+28
-23
lines changed

3 files changed

+28
-23
lines changed

Makefile

Lines changed: 23 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,12 @@ GOBIN ?= $(GOPATH)/bin
4040
DOCKER_CLI_EXPERIMENTAL = enabled
4141
export GOPATH GOBIN GO111MODULE DOCKER_CLI_EXPERIMENTAL
4242

43+
# Output type of docker buildx build
44+
OUTPUT_TYPE ?= registry
45+
46+
ALL_ARCH.linux = amd64 #arm64
47+
ALL_OS_ARCH = $(foreach arch, ${ALL_ARCH.linux}, linux-$(arch))
48+
4349
all: blob
4450

4551
.PHONY: verify
@@ -85,7 +91,7 @@ e2e-teardown:
8591

8692
.PHONY: blob
8793
blob:
88-
CGO_ENABLED=0 GOOS=linux go build -a -ldflags ${LDFLAGS} -mod vendor -o _output/blobplugin ./pkg/blobplugin
94+
CGO_ENABLED=0 GOOS=linux GOARCH=$(ARCH) go build -a -ldflags ${LDFLAGS} -mod vendor -o _output/blobplugin ./pkg/blobplugin
8995

9096
.PHONY: blob-windows
9197
blob-windows:
@@ -99,36 +105,41 @@ blob-darwin:
99105
container: blob
100106
docker build -t $(IMAGE_TAG) -f ./pkg/blobplugin/dev.Dockerfile .
101107

108+
.PHONY: container-linux
109+
container-linux:
110+
docker buildx build --pull --output=type=$(OUTPUT_TYPE) --platform="linux/$(ARCH)" \
111+
-t $(IMAGE_TAG)-linux-$(ARCH) --build-arg ARCH=$(ARCH) -f ./pkg/blobplugin/Dockerfile .
112+
102113
.PHONY: blob-container
103114
blob-container:
104115
docker buildx rm container-builder || true
105116
docker buildx create --use --name=container-builder
106-
ifdef CI
117+
107118
ifeq ($(CLOUD), AzureStackCloud)
108119
docker run --privileged --name buildx_buildkit_container-builder0 -d --mount type=bind,src=/etc/ssl/certs,dst=/etc/ssl/certs moby/buildkit:latest || true
109120
endif
110-
docker buildx build --no-cache --build-arg LDFLAGS=${LDFLAGS} -t $(IMAGE_TAG) -f ./pkg/blobplugin/Dockerfile --platform="linux/amd64" --push .
111-
112-
docker manifest create $(IMAGE_TAG) $(IMAGE_TAG)
113-
docker manifest inspect $(IMAGE_TAG)
114-
ifdef PUBLISH
115-
docker manifest create $(IMAGE_TAG_LATEST) $(IMAGE_TAG)
116-
docker manifest inspect $(IMAGE_TAG_LATEST)
117-
endif
118-
endif
121+
# enable qemu for arm64 build
122+
# docker run --rm --privileged multiarch/qemu-user-static --reset -p yes
123+
for arch in $(ALL_ARCH.linux); do \
124+
ARCH=$${arch} $(MAKE) blob; \
125+
ARCH=$${arch} $(MAKE) container-linux; \
126+
done
119127

120128
.PHONY: push
121129
push:
122130
ifdef CI
131+
docker manifest create --amend $(IMAGE_TAG) $(foreach osarch, $(ALL_OS_ARCH), $(IMAGE_TAG)-${osarch})
123132
docker manifest push --purge $(IMAGE_TAG)
133+
docker manifest inspect $(IMAGE_TAG)
124134
else
125135
docker push $(IMAGE_TAG)
126136
endif
127137

128138
.PHONY: push-latest
129139
push-latest:
130140
ifdef CI
131-
docker manifest push --purge $(IMAGE_TAG_LATEST)
141+
docker manifest create --amend $(IMAGE_TAG_LATEST) $(foreach osarch, $(ALL_OS_ARCH), $(IMAGE_TAG)-${osarch})
142+
docker manifest inspect $(IMAGE_TAG_LATEST)
132143
else
133144
docker push $(IMAGE_TAG_LATEST)
134145
endif

pkg/blob/nodeserver.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,7 @@ func (d *Driver) NodePublishVolume(ctx context.Context, req *csi.NodePublishVolu
9393

9494
klog.V(2).Infof("NodePublishVolume: volume %s mounting %s at %s with mountOptions: %v", volumeID, source, target, mountOptions)
9595
if d.enableBlobMockMount {
96+
klog.Warningf("NodePublishVolume: mock mount on volumeID(%s), this is only for TESTING!!!", volumeID)
9697
if err := volumehelper.MakeDir(target); err != nil {
9798
klog.Errorf("MakeDir failed on target: %s (%v)", target, err)
9899
return nil, err

pkg/blobplugin/Dockerfile

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -12,22 +12,15 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414

15-
FROM golang:1.16.3-alpine3.13 as builder
16-
WORKDIR /go/src/sigs.k8s.io/blob-csi-driver
17-
ADD . .
18-
ARG TARGETARCH
19-
ARG TARGETOS
20-
ARG LDFLAGS
21-
RUN CGO_ENABLED=0 GOOS=$TARGETOS GOARCH=$TARGETARCH go build -a -ldflags "${LDFLAGS:--X sigs.k8s.io/blob-csi-driver/pkg/blob.driverVersion=latest}" -mod vendor -o _output/blobplugin ./pkg/blobplugin
15+
ARG ARCH
2216

23-
FROM k8s.gcr.io/build-image/debian-base-amd64:v2.1.3
24-
COPY --from=builder /go/src/sigs.k8s.io/blob-csi-driver/_output/blobplugin /blobplugin
17+
FROM k8s.gcr.io/build-image/debian-base-${ARCH}:v2.1.3
18+
COPY ./_output/blobplugin /blobplugin
2519
RUN apt-get update && clean-install ca-certificates pkg-config libfuse-dev cmake libcurl4-gnutls-dev libgnutls28-dev uuid-dev libgcrypt20-dev wget
2620
RUN wget -O /tmp/packages-microsoft-prod.deb https://packages.microsoft.com/config/ubuntu/16.04/packages-microsoft-prod.deb && dpkg -i /tmp/packages-microsoft-prod.deb && apt-get update && apt install blobfuse fuse -y && rm -f /tmp/packages-microsoft-prod.deb
2721
RUN apt remove wget -y
2822
# this is a workaround to install nfs-common & nfs-kernel-server and don't quit with error
29-
# WIP: check if updating the kernel version would fix the below error
30-
# RUN apt update && apt install nfs-common nfs-kernel-server -y || true
23+
RUN apt-get update && apt install nfs-common nfs-kernel-server -y || true
3124
LABEL maintainers="andyzhangx"
3225
LABEL description="Azure Blob Storage CSI driver"
3326

0 commit comments

Comments
 (0)