Skip to content

Commit

Permalink
Docker and Makefile changes for ARM support
Browse files Browse the repository at this point in the history
  • Loading branch information
dlakhaws committed Nov 9, 2023
1 parent aff7e23 commit 31defe2
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 11 deletions.
28 changes: 18 additions & 10 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,14 @@ ARG MOUNTPOINT_VERSION=1.1.0
# Download and verify the mountpoint's RPM and DEB in this container
FROM --platform=$BUILDPLATFORM public.ecr.aws/amazonlinux/amazonlinux:2023 as mp_builder
ARG MOUNTPOINT_VERSION

ARG TARGETARCH
ARG TARGETPLATFORM
# We need the full version of GnuPG
RUN dnf install -y --allowerasing wget gnupg2

RUN MP_ARCH=`uname -p | sed s/aarch64/arm64/` && \
RUN echo ${BUILDPLATFORM}
RUN echo ${TARGETARCH}
RUN MP_ARCH=`echo ${TARGETARCH} | sed s/amd64/x86_64/` && \
wget -q "https://s3.amazonaws.com/mountpoint-s3-release/${MOUNTPOINT_VERSION}/$MP_ARCH/mount-s3-${MOUNTPOINT_VERSION}-$MP_ARCH.rpm" && \
wget -q "https://s3.amazonaws.com/mountpoint-s3-release/${MOUNTPOINT_VERSION}/$MP_ARCH/mount-s3-${MOUNTPOINT_VERSION}-$MP_ARCH.rpm.asc" && \
wget -q "https://s3.amazonaws.com/mountpoint-s3-release/${MOUNTPOINT_VERSION}/$MP_ARCH/mount-s3-${MOUNTPOINT_VERSION}-$MP_ARCH.deb" && \
Expand All @@ -33,34 +36,39 @@ RUN gpg --import KEYS && \
(gpg --fingerprint [email protected] | grep "673F E406 1506 BB46 9A0E F857 BE39 7A52 B086 DA5A")

# Verify the downloaded binary
RUN MP_ARCH=`uname -p | sed s/aarch64/arm64/` && \
RUN MP_ARCH=`echo ${TARGETARCH} | sed s/amd64/x86_64/` && \
gpg --verify mount-s3-${MOUNTPOINT_VERSION}-$MP_ARCH.rpm.asc && \
gpg --verify mount-s3-${MOUNTPOINT_VERSION}-$MP_ARCH.deb.asc && \
mv mount-s3-${MOUNTPOINT_VERSION}-$MP_ARCH.rpm /mount-s3.rpm && \
mv mount-s3-${MOUNTPOINT_VERSION}-$MP_ARCH.deb /mount-s3.deb

# Build driver
FROM --platform=$BUILDPLATFORM golang:1.21.1-bullseye as builder

ARG TARGETARCH
ARG TARGETPLATFORM
RUN uname -a
RUN echo $TARGETPLATFORM
WORKDIR /go/src/github.com/awslabs/mountpoint-s3-csi-driver
COPY . .
RUN --mount=type=cache,target=/root/.cache/go-build --mount=type=cache,target=/go/pkg/mod \
make bin
TARGETARCH=${TARGETARCH} make bin

FROM --platform=$BUILDPLATFORM public.ecr.aws/amazonlinux/amazonlinux:2023 AS linux-amazon
FROM --platform=$TARGETPLATFORM public.ecr.aws/eks-distro-build-tooling/eks-distro-minimal-base-csi:latest-al2 AS linux-amazon
ARG MOUNTPOINT_VERSION
ARG TARGETARCH
ARG TARGETPLATFORM
ENV MOUNTPOINT_VERSION=${MOUNTPOINT_VERSION}

RUN yum install util-linux -y
# RUN yum install util-linux -y

# MP Installer
COPY --from=mp_builder /mount-s3.rpm /mount-s3.rpm
COPY --from=mp_builder /mount-s3.deb /mount-s3.deb
COPY ./cmd/install-mp.sh /install-mp.sh

RUN dnf upgrade -y && \
dnf install -y ./mount-s3.rpm && \
dnf clean all
# RUN dnf upgrade -y && \
# dnf install -y ./mount-s3.rpm && \
# dnf clean all

# Install driver
COPY --from=builder /go/src/github.com/awslabs/mountpoint-s3-csi-driver/bin/aws-s3-csi-driver /bin/aws-s3-csi-driver
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ login_registry:
.PHONY: bin
bin:
mkdir -p bin
CGO_ENABLED=0 GOOS=linux go build -ldflags ${LDFLAGS} -o bin/aws-s3-csi-driver ./cmd/
CGO_ENABLED=0 GOOS=linux GOARCH=${TARGETARCH} go build -ldflags ${LDFLAGS} -o bin/aws-s3-csi-driver ./cmd/

.PHONY: test
test:
Expand Down

0 comments on commit 31defe2

Please sign in to comment.