-
Notifications
You must be signed in to change notification settings - Fork 77
Expand file tree
/
Copy pathDockerfile
More file actions
73 lines (61 loc) · 3.75 KB
/
Dockerfile
File metadata and controls
73 lines (61 loc) · 3.75 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
#Copyright 2022 The Kubernetes Authors
#
#Licensed under the Apache License, Version 2.0 (the "License");
#you may not use this file except in compliance with the License.
#You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
#Unless required by applicable law or agreed to in writing, software
#distributed under the License is distributed on an "AS IS" BASIS,
#WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
#See the License for the specific language governing permissions and
#limitations under the License.
ARG MOUNTPOINT_VERSION=1.22.2
# Download the mountpoint tarball and produce an installable directory
FROM --platform=$TARGETPLATFORM public.ecr.aws/amazonlinux/amazonlinux:2023 as mp_builder
ARG MOUNTPOINT_VERSION
ARG TARGETARCH
ARG TARGETPLATFORM
RUN dnf install -y gzip wget tar fuse-libs binutils patchelf && \
# gnupg2-minimal doesn't include gpg-agent needed for signature verification.
# https://docs.aws.amazon.com/linux/al2023/ug/gnupg-minimal.html
dnf swap -y gnupg2-minimal gnupg2-full
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.tar.gz" && \
wget -q "https://s3.amazonaws.com/mountpoint-s3-release/${MOUNTPOINT_VERSION}/$MP_ARCH/mount-s3-${MOUNTPOINT_VERSION}-$MP_ARCH.tar.gz.asc" && \
wget -q https://s3.amazonaws.com/mountpoint-s3-release/public_keys/KEYS
# Import the key and validate it has the fingerprints we expect
RUN gpg --import KEYS && \
(gpg --fingerprint mountpoint-s3@amazon.com | grep "8AEF E705 EBE3 29C0 948C 75A6 6F1C 3B3A EF4B 030B") && \
(gpg --fingerprint mountpoint-s3@amazon.com | grep "673F E406 1506 BB46 9A0E F857 BE39 7A52 B086 DA5A") # older key
# Verify the downloaded tarball, extract it, and fixup the binary
RUN MP_ARCH=`echo ${TARGETARCH} | sed s/amd64/x86_64/` && \
gpg --verify mount-s3-${MOUNTPOINT_VERSION}-$MP_ARCH.tar.gz.asc && \
mkdir -p /mountpoint-s3 && \
tar -xvzf mount-s3-${MOUNTPOINT_VERSION}-$MP_ARCH.tar.gz -C /mountpoint-s3 && \
# set rpath for dynamic library loading
patchelf --set-rpath '$ORIGIN' /mountpoint-s3/bin/mount-s3
# Build driver. Use BUILDPLATFORM not TARGETPLATFORM for cross compilation
FROM --platform=$BUILDPLATFORM public.ecr.aws/eks-distro-build-tooling/golang:1.26.3-al23 as builder
ARG TARGETARCH
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 \
TARGETARCH=${TARGETARCH} make generate_licenses bin
# `eks-distro-minimal-base-csi` includes `libfuse` and mount utils such as `umount`.
# We need to make sure to use same Amazon Linux version here and while producing Mountpoint to not have glibc compatibility issues.
FROM --platform=$TARGETPLATFORM public.ecr.aws/eks-distro-build-tooling/eks-distro-minimal-base-csi:latest-al23 AS linux-amazon
ARG MOUNTPOINT_VERSION
ENV MOUNTPOINT_VERSION=${MOUNTPOINT_VERSION}
ENV MOUNTPOINT_BIN_DIR=/mountpoint-s3/bin
# Copy Mountpoint binary
COPY --from=mp_builder /mountpoint-s3 /mountpoint-s3
COPY --from=mp_builder /lib64/libfuse.so.2 /mountpoint-s3/bin/
# Copy licenses of CSI Driver's dependencies
COPY --from=builder /go/src/github.com/awslabs/mountpoint-s3-csi-driver/LICENSES /LICENSES
# Copy CSI Driver binaries
COPY --from=builder /go/src/github.com/awslabs/mountpoint-s3-csi-driver/bin/aws-s3-csi-driver /bin/aws-s3-csi-driver
COPY --from=builder /go/src/github.com/awslabs/mountpoint-s3-csi-driver/bin/aws-s3-csi-controller /bin/aws-s3-csi-controller
COPY --from=builder /go/src/github.com/awslabs/mountpoint-s3-csi-driver/bin/aws-s3-csi-mounter /bin/aws-s3-csi-mounter
ENTRYPOINT ["/bin/aws-s3-csi-driver"]