Dockerfile.build 3.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. # Copyright 2017 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. FROM BASEIMAGE
  15. # If we're building for another architecture than amd64, the CROSS_BUILD_ placeholder is removed so
  16. # e.g. CROSS_BUILD_COPY turns into COPY
  17. # If we're building normally, for amd64, CROSS_BUILD lines are removed
  18. CROSS_BUILD_COPY qemu-ARCH-static /usr/bin/
  19. ENV DEBIAN_FRONTEND=noninteractive
  20. # Smaller package install size.
  21. COPY excludes /etc/dpkg/dpkg.cfg.d/excludes
  22. # Convenience script for building on this base image.
  23. COPY clean-install /usr/local/bin/clean-install
  24. # Update system packages.
  25. RUN apt-get update \
  26. && apt-get dist-upgrade -y
  27. # Hold required packages to avoid breaking the installation of packages
  28. RUN apt-mark hold apt gnupg adduser passwd libsemanage1 libcap2
  29. # Remove unnecessary packages.
  30. # This list was generated manually by listing the installed packages (`apt list --installed`),
  31. # then running `apt-cache rdepends --installed --no-recommends` to find the "root" packages.
  32. # The root packages were evaluated based on whether they were needed in the container image.
  33. # Several utilities (e.g. ping) were kept for usefulness, but may be removed in later versions.
  34. RUN echo "Yes, do as I say!" | apt-get purge \
  35. bash \
  36. e2fsprogs \
  37. libcap2-bin \
  38. libmount1 \
  39. libsmartcols1 \
  40. libblkid1 \
  41. libss2 \
  42. ncurses-base \
  43. ncurses-bin \
  44. tzdata
  45. # No-op stubs replace some unnecessary binaries that may be depended on in the install process (in
  46. # particular we don't run an init process).
  47. WORKDIR /usr/local/bin
  48. RUN touch noop && \
  49. chmod 555 noop && \
  50. ln -s noop runlevel && \
  51. ln -s noop invoke-rc.d && \
  52. ln -s noop update-rc.d
  53. WORKDIR /
  54. # Cleanup cached and unnecessary files.
  55. RUN apt-get autoremove -y && \
  56. apt-get clean -y && \
  57. tar -czf /usr/share/copyrights.tar.gz /usr/share/common-licenses /usr/share/doc/*/copyright && \
  58. rm -rf \
  59. /usr/share/doc \
  60. /usr/share/man \
  61. /usr/share/info \
  62. /usr/share/locale \
  63. /var/lib/apt/lists/* \
  64. /var/log/* \
  65. /var/cache/debconf/* \
  66. /usr/share/common-licenses* \
  67. /usr/share/bash-completion \
  68. ~/.bashrc \
  69. ~/.profile \
  70. /etc/systemd \
  71. /lib/lsb \
  72. /lib/udev \
  73. /usr/lib/x86_64-linux-gnu/gconv/IBM* \
  74. /usr/lib/x86_64-linux-gnu/gconv/EBC* && \
  75. mkdir -p /usr/share/man/man1 /usr/share/man/man2 \
  76. /usr/share/man/man3 /usr/share/man/man4 \
  77. /usr/share/man/man5 /usr/share/man/man6 \
  78. /usr/share/man/man7 /usr/share/man/man8