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