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