diff --git a/packaging/docker/Dockerfile.test b/packaging/docker/Dockerfile.test new file mode 100644 index 0000000000..3481b0c66c --- /dev/null +++ b/packaging/docker/Dockerfile.test @@ -0,0 +1,51 @@ +ARG GRAMINE_IMAGE=gramineproject/gramine:stable-focal + +FROM ${GRAMINE_IMAGE} + +# ARGs cannot be grouped since each FROM in a Dockerfile initiates a new build +# stage, resulting in the loss of ARG values from earlier stages. +ARG GRAMINE_URL=https://github.com/gramineproject/gramine.git + +RUN apt-get update && \ + DEBIAN_FRONTEND=noninteractive apt-get install -y \ + build-essential \ + autoconf \ + bison \ + gawk \ + git \ + meson \ + nasm \ + libunwind-dev \ + ninja-build \ + pkg-config \ + python3 \ + python3-click \ + python3-jinja2 \ + python3-pip \ + python3-pyelftools \ + python3-pytest \ + wget && \ + python3 -m pip install \ + 'meson>=0.56' \ + 'tomli>=1.1.0' \ + 'tomli-w>=0.4.0' && \ + apt-get clean && \ + rm -rf /var/lib/apt/lists/* + +WORKDIR /root + +RUN git clone --depth 1 --branch v$(gramine-direct --version | cut -d' ' -f2) \ + ${GRAMINE_URL} gramine && \ + cd gramine && \ + meson setup \ + build/ \ + --prefix=/usr \ + -Ddirect=disabled \ + -Dsgx=disabled \ + -Dtests=enabled && \ + meson compile -C build/ && \ + meson install -C build/ + +RUN gramine-sgx-gen-private-key + +ENTRYPOINT ["/usr/bin/gramine-test"] diff --git a/packaging/docker/test.sh b/packaging/docker/test.sh new file mode 100755 index 0000000000..d3ab711eab --- /dev/null +++ b/packaging/docker/test.sh @@ -0,0 +1,53 @@ +#!/usr/bin/env bash + + +usage() { + echo "Usage: test.sh [ubuntu20,ubuntu22]" + exit 1 +} + +if [ $# -ne 1 ]; then + usage +fi + +codename="" + +case "$1" in + ubuntu20) + codename="focal" + ;; + ubuntu22) + codename="jammy" + ;; + *) + usage + ;; +esac + +EXTRA_ARGS="" +if [ -n "${GRAMINE_URL}" ]; then + EXTRA_ARGS="--build-arg GRAMINE_URL=${GRAMINE_URL}" +fi + +tag="gramineproject/gramine:testing-stable-${codename}" +docker build \ + --build-arg GRAMINE_IMAGE="gramineproject/gramine:stable-${codename}" \ + ${EXTRA_ARGS} \ + -t "${tag}" \ + -f Dockerfile.test \ + . || exit 1 + +docker run \ + --rm \ + -t \ + --security-opt seccomp=unconfined \ + "${tag}" \ + -C /root/gramine/libos/test/regression pytest + +docker run \ + --rm \ + -t \ + --device /dev/sgx_enclave \ + --volume /var/run/aesmd/aesm.socket:/var/run/aesmd/aesm.socket \ + "${tag}" \ + -C /root/gramine/libos/test/regression --sgx pytest