swtpm/Dockerfile
Stefan Berger 607eb54b3e ci: Fix the github build action building libtpms in the container
Split the download and untarring from the build of libtpms so that the
build actually happens. Otherwise it was not building libtpms anymore but
seems to have been using a cached version of the container that had an
older version of libtpms.

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2024-09-03 14:35:33 -04:00

44 lines
1.8 KiB
Docker

FROM python:3.9-alpine3.19 as builder
LABEL org.opencontainers.image.authors="Stefan Berger"
ENV PACKAGES="curl openssl-dev automake autoconf bash build-base libtool make socat gawk libtasn1-dev gnutls gnutls-utils gnutls-dev expect libseccomp-dev softhsm py3-cryptography py3-twisted py3-setuptools json-glib-dev gmp-dev"
RUN apk add --no-cache --no-check-certificate $PACKAGES && rm -rf /var/cache/apk/*
ARG LIBTPMS_BRANCH=master
WORKDIR /src/build-prep/libtpms
SHELL ["/bin/bash", "-o", "pipefail", "-c"]
RUN curl -kL "https://github.com/stefanberger/libtpms/archive/${LIBTPMS_BRANCH}.tar.gz" \
| tar --strip=1 -zxvf - -C /src/build-prep/libtpms
RUN ./autogen.sh --prefix=/usr --libdir=/usr/lib --with-tpm2 --with-openssl \
&& make -j"$(nproc)" V=1 \
&& make -j"$(nproc)" V=1 check \
&& make -j"$(nproc)" install \
&& make DESTDIR=/app -j"$(nproc)" install
COPY . /src/build-prep/swtpm
WORKDIR /src/build-prep/swtpm
SHELL ["/bin/bash", "-o", "pipefail", "-c"]
RUN ./autogen.sh --prefix=/usr --libdir=/usr/lib --with-openssl --with-tss-user=root --with-tss-group=root \
&& make -j"$(nproc)" V=1 \
&& echo "softhsm or certtool are crashing pkcs11 test case" \
&& { for f in test_tpm2_swtpm_localca_pkcs11.test test_tpm2_samples_swtpm_localca_pkcs11; do echo -en '#!/usr/bin/env bash'"\nexit 77\n" > tests/${f}; done; } \
&& make -j"$(nproc)" V=1 VERBOSE=1 check \
&& make DESTDIR=/app -j"$(nproc)" install
FROM alpine:3.19
LABEL org.opencontainers.image.authors="Stefan Berger"
ENV PACKAGES="openssl socat gawk libtasn1 expect libseccomp softhsm py3-cryptography py3-twisted py3-setuptools json-glib gmp"
RUN apk add --no-cache --no-check-certificate $PACKAGES && rm -rf /var/cache/apk/*
COPY --from=builder /app /
WORKDIR /app
ENTRYPOINT ["/usr/bin/swtpm"]