Dockerfile 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162
  1. # Dockerfile
  2. #
  3. # Purpose
  4. # -------
  5. # Defines a Docker container suitable to build and run all tests (all.sh),
  6. # except for those that use a proprietary toolchain.
  7. # Copyright The Mbed TLS Contributors
  8. # SPDX-License-Identifier: Apache-2.0
  9. #
  10. # Licensed under the Apache License, Version 2.0 (the "License"); you may
  11. # not use this file except in compliance with the License.
  12. # You may obtain a copy of the License at
  13. #
  14. # http://www.apache.org/licenses/LICENSE-2.0
  15. #
  16. # Unless required by applicable law or agreed to in writing, software
  17. # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
  18. # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  19. # See the License for the specific language governing permissions and
  20. # limitations under the License.
  21. ARG MAKEFLAGS_PARALLEL=""
  22. ARG MY_REGISTRY=
  23. FROM ${MY_REGISTRY}ubuntu:bionic
  24. ENV DEBIAN_FRONTEND noninteractive
  25. RUN apt-get update \
  26. && apt-get -y install software-properties-common \
  27. && rm -rf /var/lib/apt/lists
  28. RUN add-apt-repository -y ppa:team-gcc-arm-embedded/ppa
  29. RUN apt-get update \
  30. && apt-get -y install \
  31. # mbedtls build/test dependencies
  32. build-essential \
  33. clang \
  34. cmake \
  35. doxygen \
  36. gcc-arm-none-eabi \
  37. gcc-mingw-w64-i686 \
  38. gcc-multilib \
  39. g++-multilib \
  40. gdb \
  41. git \
  42. graphviz \
  43. lsof \
  44. python \
  45. python3-pip \
  46. python3 \
  47. pylint3 \
  48. valgrind \
  49. wget \
  50. # libnettle build dependencies
  51. libgmp-dev \
  52. m4 \
  53. pkg-config \
  54. && rm -rf /var/lib/apt/lists/*
  55. # Build a static, legacy openssl from sources with sslv3 enabled
  56. # Based on https://gist.github.com/bmaupin/8caca3a1e8c3c5686141 (build-openssl.sh)
  57. # Note: openssl-1.0.2 and earlier has known build issues with parallel make.
  58. RUN cd /tmp \
  59. && wget https://www.openssl.org/source/old/1.0.1/openssl-1.0.1j.tar.gz -qO- | tar xz \
  60. && cd openssl-1.0.1j \
  61. && ./config --openssldir=/usr/local/openssl-1.0.1j no-shared \
  62. && (make ${MAKEFLAGS_PARALLEL} || make -j 1) \
  63. && make install_sw \
  64. && rm -rf /tmp/openssl*
  65. ENV OPENSSL_LEGACY=/usr/local/openssl-1.0.1j/bin/openssl
  66. # Build OPENSSL as 1.0.2g
  67. RUN cd /tmp \
  68. && wget https://www.openssl.org/source/old/1.0.2/openssl-1.0.2g.tar.gz -qO- | tar xz \
  69. && cd openssl-1.0.2g \
  70. && ./config --openssldir=/usr/local/openssl-1.0.2g no-shared \
  71. && (make ${MAKEFLAGS_PARALLEL} || make -j 1) \
  72. && make install_sw \
  73. && rm -rf /tmp/openssl*
  74. ENV OPENSSL=/usr/local/openssl-1.0.2g/bin/openssl
  75. # Build a new openssl binary for ARIA/CHACHA20 support
  76. # Based on https://gist.github.com/bmaupin/8caca3a1e8c3c5686141 (build-openssl.sh)
  77. RUN cd /tmp \
  78. && wget https://www.openssl.org/source/openssl-1.1.1a.tar.gz -qO- | tar xz \
  79. && cd openssl-1.1.1a \
  80. && ./config --prefix=/usr/local/openssl-1.1.1a -Wl,--enable-new-dtags,-rpath,'${LIBRPATH}' no-shared \
  81. && make ${MAKEFLAGS_PARALLEL} \
  82. && make install_sw \
  83. && rm -rf /tmp/openssl*
  84. ENV OPENSSL_NEXT=/usr/local/openssl-1.1.1a/bin/openssl
  85. # Build libnettle 2.7.1 (needed by legacy gnutls)
  86. RUN cd /tmp \
  87. && wget https://ftp.gnu.org/gnu/nettle/nettle-2.7.1.tar.gz -qO- | tar xz \
  88. && cd nettle-2.7.1 \
  89. && ./configure --disable-documentation \
  90. && make ${MAKEFLAGS_PARALLEL} \
  91. && make install \
  92. && /sbin/ldconfig \
  93. && rm -rf /tmp/nettle*
  94. # Build legacy gnutls (3.3.8)
  95. RUN cd /tmp \
  96. && wget https://www.gnupg.org/ftp/gcrypt/gnutls/v3.3/gnutls-3.3.8.tar.xz -qO- | tar xJ \
  97. && cd gnutls-3.3.8 \
  98. && ./configure --prefix=/usr/local/gnutls-3.3.8 --exec_prefix=/usr/local/gnutls-3.3.8 --disable-shared --disable-guile --disable-doc \
  99. && make ${MAKEFLAGS_PARALLEL} \
  100. && make install \
  101. && rm -rf /tmp/gnutls*
  102. ENV GNUTLS_LEGACY_CLI=/usr/local/gnutls-3.3.8/bin/gnutls-cli
  103. ENV GNUTLS_LEGACY_SERV=/usr/local/gnutls-3.3.8/bin/gnutls-serv
  104. # Build libnettle 3.1 (needed by gnutls)
  105. RUN cd /tmp \
  106. && wget https://ftp.gnu.org/gnu/nettle/nettle-3.1.tar.gz -qO- | tar xz \
  107. && cd nettle-3.1 \
  108. && ./configure --disable-documentation \
  109. && make ${MAKEFLAGS_PARALLEL} \
  110. && make install \
  111. && /sbin/ldconfig \
  112. && rm -rf /tmp/nettle*
  113. # Build gnutls (3.4.10)
  114. RUN cd /tmp \
  115. && wget https://www.gnupg.org/ftp/gcrypt/gnutls/v3.4/gnutls-3.4.10.tar.xz -qO- | tar xJ \
  116. && cd gnutls-3.4.10 \
  117. && ./configure --prefix=/usr/local/gnutls-3.4.10 --exec_prefix=/usr/local/gnutls-3.4.10 \
  118. --with-included-libtasn1 --without-p11-kit \
  119. --disable-shared --disable-guile --disable-doc \
  120. && make ${MAKEFLAGS_PARALLEL} \
  121. && make install \
  122. && rm -rf /tmp/gnutls*
  123. ENV GNUTLS_CLI=/usr/local/gnutls-3.4.10/bin/gnutls-cli
  124. ENV GNUTLS_SERV=/usr/local/gnutls-3.4.10/bin/gnutls-serv
  125. # Build libnettle 3.4 (needed by gnutls next)
  126. RUN cd /tmp \
  127. && wget https://ftp.gnu.org/gnu/nettle/nettle-3.4.1.tar.gz -qO- | tar xz \
  128. && cd nettle-3.4.1 \
  129. && ./configure --disable-documentation \
  130. && make ${MAKEFLAGS_PARALLEL} \
  131. && make install \
  132. && /sbin/ldconfig \
  133. && rm -rf /tmp/nettle*
  134. # Build gnutls next (3.6.5)
  135. RUN cd /tmp \
  136. && wget https://www.gnupg.org/ftp/gcrypt/gnutls/v3.6/gnutls-3.6.5.tar.xz -qO- | tar xJ \
  137. && cd gnutls-3.6.5 \
  138. && ./configure --prefix=/usr/local/gnutls-3.6.5 --exec_prefix=/usr/local/gnutls-3.6.5 \
  139. --with-included-libtasn1 --with-included-unistring --without-p11-kit \
  140. --disable-shared --disable-guile --disable-doc \
  141. && make ${MAKEFLAGS_PARALLEL} \
  142. && make install \
  143. && rm -rf /tmp/gnutls*
  144. ENV GNUTLS_NEXT_CLI=/usr/local/gnutls-3.6.5/bin/gnutls-cli
  145. ENV GNUTLS_NEXT_SERV=/usr/local/gnutls-3.6.5/bin/gnutls-serv