Dockerfile.build 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  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. debconf-i18n \
  37. e2fslibs \
  38. e2fsprogs \
  39. init \
  40. initscripts \
  41. libcap2-bin \
  42. libkmod2 \
  43. libmount1 \
  44. libsmartcols1 \
  45. libudev1 \
  46. libblkid1 \
  47. libncursesw5 \
  48. libprocps6 \
  49. libslang2 \
  50. libss2 \
  51. libsystemd0 \
  52. libtext-charwidth-perl libtext-iconv-perl libtext-wrapi18n-perl \
  53. ncurses-base \
  54. ncurses-bin \
  55. systemd \
  56. systemd-sysv \
  57. sysv-rc \
  58. tzdata
  59. # No-op stubs replace some unnecessary binaries that may be depended on in the install process (in
  60. # particular we don't run an init process).
  61. WORKDIR /usr/local/bin
  62. RUN touch noop && \
  63. chmod 555 noop && \
  64. ln -s noop runlevel && \
  65. ln -s noop invoke-rc.d && \
  66. ln -s noop update-rc.d
  67. WORKDIR /
  68. # Cleanup cached and unnecessary files.
  69. RUN apt-get autoremove -y && \
  70. apt-get clean -y && \
  71. tar -czf /usr/share/copyrights.tar.gz /usr/share/common-licenses /usr/share/doc/*/copyright && \
  72. rm -rf \
  73. /usr/share/doc \
  74. /usr/share/man \
  75. /usr/share/info \
  76. /usr/share/locale \
  77. /var/lib/apt/lists/* \
  78. /var/log/* \
  79. /var/cache/debconf/* \
  80. /usr/share/common-licenses* \
  81. /usr/share/bash-completion \
  82. ~/.bashrc \
  83. ~/.profile \
  84. /etc/systemd \
  85. /lib/lsb \
  86. /lib/udev \
  87. /usr/lib/x86_64-linux-gnu/gconv/IBM* \
  88. /usr/lib/x86_64-linux-gnu/gconv/EBC* && \
  89. mkdir -p /usr/share/man/man1 /usr/share/man/man2 \
  90. /usr/share/man/man3 /usr/share/man/man4 \
  91. /usr/share/man/man5 /usr/share/man/man6 \
  92. /usr/share/man/man7 /usr/share/man/man8