-
Notifications
You must be signed in to change notification settings - Fork 26
Expand file tree
/
Copy pathDockerfile
More file actions
74 lines (65 loc) · 2.94 KB
/
Dockerfile
File metadata and controls
74 lines (65 loc) · 2.94 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
# Build the TPM simulator using CMake from a regular Ubuntu container
FROM ubuntu:24.04
ARG DEBIAN_FRONTEND=noninteractive
# Install some basic tools we're going to need to build the simulator.
# Put this first so local docker will cache this step before copying in the code that
# will get built. This saves a lot of time on Windows development hosts.
# Install OpenSSH (useful for GitHub Actions that need to authenticate to
# private Git repositories) and gcovr (for generating code coverage reports)
# Install zip so we can zip up coverage reports.
RUN apt-get update && apt-get install -y \
build-essential \
cmake \
gcc \
git \
libssl-dev \
openssh-client \
pipx \
pkg-config \
wget \
zip \
&& rm -rf /var/lib/apt/lists/*
RUN pipx install gcovr
# Install .NET 8
RUN apt-get update && apt-get install -y dotnet-sdk-8.0
# copy the source tree into a temporary build tree.
WORKDIR /build
COPY TPMCmd ./TPMCmd
# enable building with code coverage
ENV CFLAGS=--coverage
################################################################################
# OpenSSL-based simulators
################################################################################
# Ubuntu 22.04 comes with OpenSSL 3
# After the build, delete everything but the files needed for coverage analysis
RUN mkdir -p /simulators/openssl3 && \
cd /simulators/openssl3 && \
cp -r /build/TPMCmd/* . && \
cmake -S . -B DebugLinuxOpenSSL3 && \
cmake --build DebugLinuxOpenSSL3 --parallel && \
find . -type f -not -regex '.*Simulator\|.*\.gcno\|.*\.c\|.*\.h' -exec rm {} \; && \
ln -s ./DebugLinuxOpenSSL3/Simulator/Simulator tpm2-simulator
# Roll back to OpenSSL 1.1 and build again
# After the build, delete everything but the files needed for coverage analysis
RUN if [ $(arch) = "x86_64" ]; then \
LIBSSL_DEB_PATH=http://security.ubuntu.com/ubuntu/pool/main/o/openssl/libssl1.1_1.1.1-1ubuntu2.1~18.04.23_amd64.deb; \
LIBSSL_DEV_DEB_PATH=http://security.ubuntu.com/ubuntu/pool/main/o/openssl/libssl-dev_1.1.1-1ubuntu2.1~18.04.23_amd64.deb; \
else \
LIBSSL_DEB_PATH=http://ports.ubuntu.com/pool/main/o/openssl/libssl1.1_1.1.1-1ubuntu2.1~18.04.23_arm64.deb; \
LIBSSL_DEV_DEB_PATH=http://ports.ubuntu.com/pool/main/o/openssl/libssl-dev_1.1.1-1ubuntu2.1~18.04.23_arm64.deb; \
fi && \
mkdir -p /ossl1 && \
cd /ossl1 && \
wget ${LIBSSL_DEB_PATH} -O libssl.deb && \
dpkg -i libssl.deb && \
wget ${LIBSSL_DEV_DEB_PATH} -O libssl-dev.deb && \
dpkg -i libssl-dev.deb
RUN mkdir -p /simulators/openssl1 && \
cd /simulators/openssl1 && \
cp -r /build/TPMCmd/* . && \
cmake -S . -B DebugLinuxOpenSSL1 && \
cmake --build DebugLinuxOpenSSL1 --parallel && \
find . -type f -not -regex '.*Simulator\|.*\.gcno\|.*\.c\|.*\.h' -exec rm {} \; && \
ln -s ./DebugLinuxOpenSSL1/Simulator/Simulator tpm2-simulator
# Symlink /tpm2-simulator to the openssl1 one, for convenience of users who just want "a" simulator.
RUN ln -s /simulators/openssl1/tpm2-simulator /tpm2-simulator