forked from intel/pmem-csi
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Dockerfile
114 lines (100 loc) · 5.23 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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
# CLEARLINUX_BASE and SWUPD_UPDATE_ARG can be used to make the build reproducible
# by choosing an image by its hash and updating to a certain version with -V:
# CLEAR_LINUX_BASE=clearlinux@sha256:b8e5d3b2576eb6d868f8d52e401f678c873264d349e469637f98ee2adf7b33d4
# SWUPD_UPDATE_ARG=-V 29970
#
# This is used on release branches before tagging a stable version. The master and devel
# branches default to using the latest Clear Linux.
ARG CLEAR_LINUX_BASE=clearlinux:latest
ARG SWUPD_UPDATE_ARG=
# Common base image for building PMEM-CSI:
# - up-to-date Clear Linux
# - ndctl installed
FROM ${CLEAR_LINUX_BASE} AS build
ARG CLEAR_LINUX_BASE
ARG SWUPD_UPDATE_ARG
ARG NDCTL_VERSION="68"
ARG NDCTL_CONFIGFLAGS="--disable-docs --without-systemd --without-bash"
ARG NDCTL_BUILD_DEPS="os-core-dev devpkg-util-linux devpkg-kmod devpkg-json-c"
ARG GO_VERSION="1.13.4"
#pull dependencies required for downloading and building libndctl
ARG CACHEBUST
RUN echo "Updating build image from ${CLEAR_LINUX_BASE} to ${SWUPD_UPDATE_ARG:-the latest release}."
RUN swupd update ${SWUPD_UPDATE_ARG} && swupd bundle-add ${NDCTL_BUILD_DEPS} c-basic && rm -rf /var/lib/swupd /var/tmp/swupd
RUN curl -L https://dl.google.com/go/go${GO_VERSION}.linux-amd64.tar.gz | tar -zxf - -C / && \
mkdir -p /usr/local/bin/ && \
for i in /go/bin/*; do ln -s $i /usr/local/bin/; done
WORKDIR /
RUN curl --fail --location --remote-name https://github.com/pmem/ndctl/archive/v${NDCTL_VERSION}.tar.gz
RUN tar zxvf v${NDCTL_VERSION}.tar.gz && mv ndctl-${NDCTL_VERSION} ndctl
WORKDIR /ndctl
RUN ./autogen.sh
# We install into /usr/local (keeps content separate from OS) but
# then symlink the .pc files to ensure that they are found without
# having to set PKG_CONFIG_PATH. The .pc file doesn't contain an -rpath
# and thus linked binaries do not find the shared libs unless we
# also symlink those.
RUN ./configure --prefix=/usr/local ${NDCTL_CONFIGFLAGS}
RUN make install && \
ln -s /usr/local/lib/pkgconfig/libndctl.pc /usr/lib64/pkgconfig/ && \
ln -s /usr/local/lib/pkgconfig/libdaxctl.pc /usr/lib64/pkgconfig/ && \
for i in /usr/local/lib/lib*.so.*; do ln -s $i /usr/lib64; done
# The source archive has no license file. We link to the copy in GitHub instead.
RUN echo "For source code and licensing of ndctl, see https://github.com/pmem/ndctl/blob/v${NDCTL_VERSION}/COPYING" >/usr/local/lib/NDCTL.COPYING
# Clean image for deploying PMEM-CSI.
FROM ${CLEAR_LINUX_BASE} as runtime
ARG CLEAR_LINUX_BASE
ARG SWUPD_UPDATE_ARG
LABEL maintainers="Intel"
LABEL description="PMEM CSI Driver"
# update and install needed bundles:
# file - driver uses file utility to determine filesystem type
# xfsprogs - XFS filesystem utilities
# storge-utils - for lvm2 and ext4(e2fsprogs) utilities
ARG CACHEBUST
RUN echo "Updating runtime image from ${CLEAR_LINUX_BASE} to ${SWUPD_UPDATE_ARG:-the latest release}."
RUN swupd update ${SWUPD_UPDATE_ARG} && swupd bundle-add file xfsprogs storage-utils && rm -rf /var/lib/swupd /var/tmp/swupd
# Image in which PMEM-CSI binaries get built.
FROM build as binaries
# build pmem-csi-driver
ARG VERSION="unknown"
ADD . /src/pmem-csi
ENV PKG_CONFIG_PATH=/usr/lib/pkgconfig/
WORKDIR /src/pmem-csi
ARG BIN_SUFFIX
# If "docker build" is invoked with the "vendor" directory correctly
# populated, then this argument can be set to -mod=vendor. "make
# build-images" does both automatically.
ARG GOFLAGS=
# Here we choose explicitly which binaries we want in the image and in
# which flavor (production or testing). The actual binary name in the
# image is going to be the same, to avoid unnecessary deployment
# differences.
RUN set -x && \
make VERSION=${VERSION} pmem-csi-driver${BIN_SUFFIX} pmem-vgm${BIN_SUFFIX} pmem-ns-init${BIN_SUFFIX} && \
mkdir -p /usr/local/bin && \
mv _output/pmem-csi-driver${BIN_SUFFIX} /usr/local/bin/pmem-csi-driver && \
mv _output/pmem-vgm${BIN_SUFFIX} /usr/local/bin/pmem-vgm && \
mv _output/pmem-ns-init${BIN_SUFFIX} /usr/local/bin/pmem-ns-init && \
mkdir -p /usr/local/share/package-licenses && \
hack/copy-modules-license.sh /usr/local/share/package-licenses ./cmd/pmem-csi-driver ./cmd/pmem-vgm ./cmd/pmem-ns-init && \
cp /go/LICENSE /usr/local/share/package-licenses/go.LICENSE && \
cp LICENSE /usr/local/share/package-licenses/PMEM-CSI.LICENSE
# The actual pmem-csi-driver image.
FROM runtime as pmem
# Move required binaries and libraries to clean container.
# All of our custom content is in /usr/local.
COPY --from=binaries /usr/local/lib/libndctl.so.* /usr/local/lib/
COPY --from=binaries /usr/local/lib/libdaxctl.so.* /usr/local/lib/
# We need to overwrite the system libs, hence -f here.
RUN for i in /usr/local/lib/lib*.so.*; do ln -fs $i /usr/lib64; done
COPY --from=binaries /usr/local/bin/pmem-* /usr/local/bin/
COPY --from=binaries /usr/local/share/package-licenses /usr/local/share/package-licenses
COPY --from=binaries /usr/local/lib/NDCTL.COPYING /usr/local/share/package-licenses/
# default lvm config uses lvmetad and throwing below warning for all lvm tools
# WARNING: Failed to connect to lvmetad. Falling back to device scanning.
# So, ask lvm not to use lvmetad
RUN mkdir -p /etc/lvm
RUN echo "global { use_lvmetad = 0 }" >> /etc/lvm/lvm.conf && \
echo "activation { udev_sync = 0 udev_rules = 0 }" >> /etc/lvm/lvm.conf
ENV LD_LIBRARY_PATH=/usr/lib