-
Notifications
You must be signed in to change notification settings - Fork 26
/
Dockerfile
68 lines (57 loc) · 3.19 KB
/
Dockerfile
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
#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.10.0
# Download the mountpoint tarball and produce an installable directory
# Building on Amazon Linux 2 because it has an old libc version. libfuse from the os
# is being packaged up in the container and a newer version linking to a too new glibc
# can cause portability issues
FROM --platform=$TARGETPLATFORM public.ecr.aws/amazonlinux/amazonlinux:2 as mp_builder
ARG MOUNTPOINT_VERSION
ARG TARGETARCH
ARG TARGETPLATFORM
# We need the full version of GnuPG
RUN yum install -y gzip wget gnupg2 tar fuse-libs binutils patchelf
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 fingerprint we expect
RUN gpg --import KEYS && \
(gpg --fingerprint [email protected] | grep "673F E406 1506 BB46 9A0E F857 BE39 7A52 B086 DA5A")
# 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/docker/library/golang:1.22-bullseye 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 bin
FROM --platform=$TARGETPLATFORM public.ecr.aws/eks-distro-build-tooling/eks-distro-minimal-base:latest AS linux-amazon
ARG MOUNTPOINT_VERSION
ENV MOUNTPOINT_VERSION=${MOUNTPOINT_VERSION}
ENV MOUNTPOINT_BIN_DIR=/mountpoint-s3/bin
# MP Installer
COPY --from=mp_builder /mountpoint-s3 /mountpoint-s3
COPY --from=mp_builder /lib64/libfuse.so.2 /mountpoint-s3/bin/
COPY --from=mp_builder /lib64/libgcc_s.so.1 /mountpoint-s3/bin/
# Install driver
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/install-mp /bin/install-mp
ENTRYPOINT ["/bin/aws-s3-csi-driver"]