# Copyright 2026 Contributors to the Parsec project.
# SPDX-License-Identifier: Apache-2.0
#
# Self-contained Ubuntu image for run-ci-locally.sh.
# Includes everything every CI job needs.

FROM ubuntu:22.04

RUN apt-get update && apt-get install -y \
    autoconf autoconf-archive automake build-essential doxygen pkg-config \
    libtool libcmocka0 libcmocka-dev libcurl4-openssl-dev libftdi-dev libini-config-dev \
    libjson-c-dev libltdl-dev libssl-dev libusb-1.0-0-dev uthash-dev uuid-dev \
    swtpm swtpm-tools llvm clang pkg-config \
    curl git valgrind codespell tpm2-tools rsync \
    && rm -rf /var/lib/apt/lists/*

RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs \
    | bash -s -- -y --default-toolchain stable --profile minimal \
        --component rustfmt --component clippy
ENV PATH="/root/.cargo/bin:${PATH}"

RUN rustup toolchain install 1.85.0 --profile minimal \
        --component rustfmt --component clippy

RUN cargo install cargo-valgrind

# Download and install the TSS library
ENV TPM2_TSS_BINDINGS_VERSION=4.1.3
ARG TPM2_TSS_VERSION=$TPM2_TSS_BINDINGS_VERSION
ENV TPM2_TSS_VERSION=$TPM2_TSS_VERSION
ENV PKG_CONFIG_PATH=/usr/local/lib/pkgconfig

RUN git clone https://github.com/tpm2-software/tpm2-tss.git --branch $TPM2_TSS_VERSION
RUN cd tpm2-tss \
	&& ./bootstrap \
	&& ./configure \
	&& make -j$(nproc) \
	&& make install \
	&& ldconfig \
    && rm -rf /tpm2-tss
