Skip to content

Commit 4a891a2

Browse files
committed
ci: reintroduce docker image caching
1 parent fa03239 commit 4a891a2

14 files changed

+918
-87
lines changed

.github/actions/build-docker/action.yml

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,13 @@ inputs:
1111
runs:
1212
using: "composite"
1313
steps:
14-
- name: "Load Docker cache"
15-
uses: satackey/[email protected]
14+
- name: Expose GitHub Runtime
15+
uses: crazy-max/ghaction-github-runtime@v2
1616

1717
- name: "Build Docker image"
1818
shell: bash
1919
run: |
20-
docker build -t ${{ inputs.docker_tag }} ${{ inputs.docker_folder_path }}
21-
20+
docker buildx create --use --driver=docker-container
21+
docker buildx build -t ${{ inputs.docker_tag }} \
22+
--cache-to="type=gha,mode=max" --cache-from="type=gha" \
23+
${{ inputs.docker_folder_path }} --load

.github/workflows/ci.yml

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,6 @@ env:
1010
DOCKER_TAG: buildenv
1111
DOCKER_FOLDER_PATH: ./dockerfiles/base
1212

13-
# This buildenv contains libp11/softhsm and libdilithium
14-
DOCKER_WITH_FEATURE_TAG: buildenv_with_features
15-
DOCKER_WITH_FEATURE_FOLDER_PATH: ./dockerfiles/feature-support
16-
1713
TOKEN_LABEL1: token-label
1814
TOKEN_LABEL2: token-label2
1915
USER_PIN: 1234
@@ -82,13 +78,6 @@ jobs:
8278
docker_tag: ${{ env.DOCKER_TAG }}
8379
docker_folder_path: ${{ env.DOCKER_FOLDER_PATH }}
8480

85-
- name: "Build Docker Image With HSM"
86-
if: ${{ matrix.hsm_flag == 'MOCOCRW_HSM_ENABLED=ON' || matrix.dilithium_flag == 'MOCOCRW_DILITHIUM_ENABLED=ON' }}
87-
uses: ./.github/actions/build-docker
88-
with:
89-
docker_tag: ${{ env.DOCKER_WITH_FEATURE_TAG }}
90-
docker_folder_path: ${{ env.DOCKER_WITH_FEATURE_FOLDER_PATH }}
91-
9281
- name: "Build MoCOCrW"
9382
run: |
9483
mkdir build

dockerfiles/base/Dockerfile

Lines changed: 80 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM ubuntu:focal
1+
FROM ubuntu:focal as base
22

33
# Install MoCOCrW dependencies (except OpenSSL)
44
RUN apt-get update && DEBIAN_FRONTEND=noninteractive apt-get -y --no-install-recommends install \
@@ -18,5 +18,82 @@ RUN apt-get update && DEBIAN_FRONTEND=noninteractive apt-get -y --no-install-rec
1818
make \
1919
ninja-build \
2020
pkg-config \
21-
wget \
22-
&& rm -rf /var/lib/apt/lists/*
21+
wget
22+
23+
FROM base as hsm
24+
25+
ARG LIBP11_URL=https://github.com/OpenSC/libp11/releases/download/libp11-0.4.12/libp11-0.4.12.tar.gz
26+
COPY hsm-patches/0001-Introduce-generic-keypair-generation-interface-and-e.patch \
27+
dilithium-patches/0001-CMakeLists.txt-Add-BUILD_TESTING-compile-flag.patch \
28+
dilithium-patches/0002-CMakeLists.txt-Enable-parallel-test-execution.patch \
29+
dilithium-patches/0003-CMakeLists.txt-Enable-PIE-compilation-flag.patch \
30+
dilithium-patches/0004-CMakeLists.txt-Add-UBSAN-and-ASAN-build-types.patch \
31+
dilithium-patches/0005-CMakeLists.txt-Add-cmake-install-target.patch \
32+
dilithium-patches/0006-CMakelists.txt-Add-stack-protector-strong-flag.patch \
33+
dilithium-patches/0007-CMakeLists.txt-Change-target_compile_definition.patch \
34+
dilithium-patches/0008-Add-function-for-pub-key-extraction.patch \
35+
/tmp/patches/
36+
37+
# Install:
38+
# * MoCOCrW dependencies (except OpenSSL)
39+
# * libp11
40+
# * libdilithium
41+
RUN apt-get update && DEBIAN_FRONTEND=noninteractive apt-get -y --no-install-recommends install \
42+
# for pkcs11-tool which we use to create keys in token
43+
opensc \
44+
# p11-kit-modules allows loading of libp11 engine without having to edit openssl.cnf
45+
p11-kit-modules \
46+
# softhsm2: includes both softhsm2-util and libsofthsm2
47+
softhsm2 \
48+
# libp11 needs this
49+
libtool && \
50+
rm -rf /var/lib/apt/lists/*
51+
52+
# Build libp11
53+
RUN mkdir -p /tmp/libp11 && \
54+
cd /tmp/libp11 && \
55+
wget "${LIBP11_URL}" && \
56+
tar xf libp11-0.4.12.tar.gz && \
57+
cd libp11-0.4.12 && \
58+
git apply /tmp/patches/0001-Introduce-generic-keypair-generation-interface-and-e.patch && \
59+
echo "Successfully patched libp11" && \
60+
autoreconf --verbose --install --force && \
61+
./configure --enable-strict && \
62+
make -j"$(nproc)" && \
63+
make check && \
64+
make install && \
65+
rm -rf /tmp/libp11
66+
67+
FROM base as dilithium
68+
RUN mkdir /tmp/patches
69+
COPY dilithium-patches/0001-CMakeLists.txt-Add-BUILD_TESTING-compile-flag.patch \
70+
dilithium-patches/0002-CMakeLists.txt-Enable-parallel-test-execution.patch \
71+
dilithium-patches/0003-CMakeLists.txt-Enable-PIE-compilation-flag.patch \
72+
dilithium-patches/0004-CMakeLists.txt-Add-UBSAN-and-ASAN-build-types.patch \
73+
dilithium-patches/0005-CMakeLists.txt-Add-cmake-install-target.patch \
74+
dilithium-patches/0006-CMakelists.txt-Add-stack-protector-strong-flag.patch \
75+
dilithium-patches/0007-CMakeLists.txt-Change-target_compile_definition.patch \
76+
dilithium-patches/0008-Add-function-for-pub-key-extraction.patch \
77+
/tmp/patches/
78+
RUN mkdir /tmp/libdilithium && \
79+
cd /tmp/libdilithium && \
80+
git clone https://github.com/pq-crystals/dilithium && \
81+
cd dilithium && \
82+
git checkout 3e9b9f1412f6c7435dbeb4e10692ea58f181ee51 && \
83+
git apply /tmp/patches/0001-CMakeLists.txt-Add-BUILD_TESTING-compile-flag.patch && \
84+
git apply /tmp/patches/0002-CMakeLists.txt-Enable-parallel-test-execution.patch && \
85+
git apply /tmp/patches/0003-CMakeLists.txt-Enable-PIE-compilation-flag.patch && \
86+
git apply /tmp/patches/0004-CMakeLists.txt-Add-UBSAN-and-ASAN-build-types.patch && \
87+
git apply /tmp/patches/0005-CMakeLists.txt-Add-cmake-install-target.patch && \
88+
git apply /tmp/patches/0006-CMakelists.txt-Add-stack-protector-strong-flag.patch && \
89+
git apply /tmp/patches/0007-CMakeLists.txt-Change-target_compile_definition.patch && \
90+
git apply /tmp/patches/0008-Add-function-for-pub-key-extraction.patch && \
91+
mkdir build && \
92+
cd build && \
93+
cmake -GNinja .. -DBUILD_TESTING=ON&& \
94+
ninja && \
95+
ctest -j"$(nproc)" && \
96+
ninja install && \
97+
cd / && \
98+
rm -rf /tmp/libdilithium && \
99+
rm -rf /tmp/patches

0 commit comments

Comments
 (0)