Debian Codegraph @

images/local-path-helper/Dockerfile

raw
1 # Copyright 2022 The Kubernetes Authors.
2 #
3 # Licensed under the Apache License, Version 2.0 (the "License");
4 # you may not use this file except in compliance with the License.
5 # You may obtain a copy of the License at
6 #
7 # http://www.apache.org/licenses/LICENSE-2.0
8 #
9 # Unless required by applicable law or agreed to in writing, software
10 # distributed under the License is distributed on an "AS IS" BASIS,
11 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 # See the License for the specific language governing permissions and
13 # limitations under the License.
14
15 # This image is contains the binaries needed for the local-path-provisioner
16 # helper pod. Currently that means: sh, rm, mkdir
17
18 ARG BASE="registry.k8s.io/build-image/debian-base:bullseye-v1.4.3"
19 FROM ${BASE} AS build
20
21 # NOTE: copyrights.tar.gz is a quirk of Kubernetes's debian-base image
22 # We extract these here so we can grab the relevant files are easily
23 # staged for copying into our final image.
24 RUN [ ! -f /usr/share/copyrights.tar.gz ] || tar -C / -xzvf /usr/share/copyrights.tar.gz
25
26 # we need bash for stage-binary-and-deps.sh
27 RUN apt update && apt install -y --no-install-recommends bash
28 # replace sh with bash
29 RUN ln -sf /bin/bash /bin/sh
30
31 # copy in script for staging distro provided binary to distroless
32 COPY --chmod=0755 stage-binary-and-deps.sh /usr/local/bin/
33
34 # local-path-provisioner needs these things for the helper pod
35 # TODO: we could probably coerce local-path-provisioner to use a small binary
36 # for these instead
37 ARG STAGE_DIR="/opt/stage"
38 RUN mkdir -p "${STAGE_DIR}" && \
39 stage-binary-and-deps.sh sh "${STAGE_DIR}" && \
40 stage-binary-and-deps.sh rm "${STAGE_DIR}" && \
41 stage-binary-and-deps.sh mkdir "${STAGE_DIR}" && \
42 find "${STAGE_DIR}"
43
44 # copy staged binary + deps + copyright into distroless
45 FROM "gcr.io/distroless/static-debian11"
46 ARG STAGE_DIR="/opt/stage"
47 COPY --from=build "${STAGE_DIR}/" /