-
Notifications
You must be signed in to change notification settings - Fork 35
/
Copy pathDockerfile.local
81 lines (67 loc) · 2.78 KB
/
Dockerfile.local
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
74
75
76
77
78
79
80
81
# A Dockerfile that builds the CSI Driver by compiling Mountpoint from its source.
# This is useful for testing unreleased Mountpoint versions.
#
# Configuration
#
ARG MOUNTPOINT_REPOSITORY="https://github.com/awslabs/mountpoint-s3"
ARG MOUNTPOINT_BRANCH="main"
ARG MOUNTPOINT_VERSION="unreleased"
ARG MOUNTPOINT_BUILD_ARGS="" # e.g., --features express_cache
#
# Build Mountpoint
#
FROM --platform=$TARGETPLATFORM amazonlinux:2023 as mp_builder
ARG MOUNTPOINT_REPOSITORY
ARG MOUNTPOINT_BRANCH
ARG MOUNTPOINT_BUILD_ARGS
# Install build tools
RUN dnf upgrade -y && \
dnf install -y \
fuse \
fuse-devel \
cmake3 \
clang \
git \
pkg-config && \
dnf clean all
# Install Rust
RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y
ENV PATH="/root/.cargo/bin:${PATH}"
# Clone Mountpoint
RUN git clone --recurse-submodules -j8 \
--single-branch --branch ${MOUNTPOINT_BRANCH} --depth 1 \
${MOUNTPOINT_REPOSITORY} mountpoint-s3
# Build Mountpoint
RUN cd mountpoint-s3 && \
cargo build ${MOUNTPOINT_BUILD_ARGS} --release
#
# Build CSI Driver
#
# Use BUILDPLATFORM not TARGETPLATFORM for cross compilation
FROM --platform=$BUILDPLATFORM public.ecr.aws/docker/library/golang:1.24-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
#
# Build the final image
#
# `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 building 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/target/release/mount-s3 /mountpoint-s3/bin/mount-s3
# TODO: These won't be necessary with containerization.
COPY --from=mp_builder /lib64/libfuse.so.2 /mountpoint-s3/bin/
COPY --from=mp_builder /lib64/libgcc_s.so.1 /mountpoint-s3/bin/
# 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
# TODO: This won't be necessary with containerization.
COPY --from=builder /go/src/github.com/awslabs/mountpoint-s3-csi-driver/bin/install-mp /bin/install-mp
ENTRYPOINT ["/bin/aws-s3-csi-driver"]