From 67d6347a7f6c5eb694001301cc2fbd971e31eed0 Mon Sep 17 00:00:00 2001 From: "Lucas, John P." Date: Wed, 14 Aug 2024 06:58:37 -0400 Subject: [PATCH 1/3] [nasa/cryptolib#262] Created top level helper Makefile; --- Makefile | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 Makefile diff --git a/Makefile b/Makefile new file mode 100644 index 00000000..013a1d27 --- /dev/null +++ b/Makefile @@ -0,0 +1,35 @@ +# +# CryptoLib Makefile +# + +# The "LOCALTGTS" defines the top-level targets that are implemented in this makefile +# Any other target may also be given, in that case it will simply be passed through. +LOCALTGTS := all clean debug internal kmc wolf +OTHERTGTS := $(filter-out $(LOCALTGTS),$(MAKECMDGOALS)) + +# As this makefile does not build any real files, treat everything as a PHONY target +# This ensures that the rule gets executed even if a file by that name does exist +.PHONY: $(LOCALTGTS) $(OTHERTGTS) + +# +# Commands +# +all: + $(MAKE) internal + $(MAKE) kmc + $(MAKE) wolf + +clean: + rm -rf ./build + +debug: + ./support/scripts/docker_debug.sh + +internal: + ./support/scripts/internal_docker_build.sh + +kmc: + ./support/scripts/kmc_docker_build.sh + +wolf: + ./support/scripts/wolf_docker_build.sh From 63a91838d2d38c0b33ff8b80a9a289d207254a13 Mon Sep 17 00:00:00 2001 From: "Lucas, John P." Date: Wed, 14 Aug 2024 07:58:51 -0400 Subject: [PATCH 2/3] [nasa/cryptolib#262] Dockerfile updates to use buildx, pushed specific 20240814 version to hub, and specified it for use; --- support/Dockerfile | 24 +++++++++++++++++------- support/scripts/docker_debug.sh | 2 +- support/scripts/env.sh | 2 ++ support/scripts/internal_docker_build.sh | 4 ++-- support/scripts/kmc_docker_build.sh | 4 ++-- support/scripts/wolf_docker_build.sh | 4 ++-- 6 files changed, 26 insertions(+), 14 deletions(-) diff --git a/support/Dockerfile b/support/Dockerfile index 08b55592..617d54a5 100644 --- a/support/Dockerfile +++ b/support/Dockerfile @@ -1,11 +1,23 @@ # CryptoLib Dockerfile # -# docker build -t ivvitc/cryptolib:latest . -# docker push ivvitc/cryptolib:latest +# Install latest docker from PPA: https://docs.docker.com/engine/install/ubuntu/ +# +# Debugging +# docker build -t ivvitc/cryptolib:dev . +# docker run -it ivvitc/cryptolib:dev /bin/bash # +# Follow multi-arch instructions: https://www.docker.com/blog/multi-arch-images/ +# docker login +# docker buildx create --name clbuilder +# docker buildx use clbuilder +# docker buildx build --platform linux/amd64 -t ivvitc/cryptolib:dev --push . +# +# TODO: +# docker buildx build --platform linux/amd64,linux/arm64 -t ivvitc/cryptolib:dev --push . +# ARG WOLFSSL_VERSION=5.6.0-stable -FROM ubuntu:jammy-20240212 AS CL0 +FROM ubuntu:jammy-20240530 AS cl0 ARG DEBIAN_FRONTEND=noninteractive RUN apt-get update -y \ @@ -15,8 +27,6 @@ RUN apt-get update -y \ ca-certificates \ cmake \ curl \ - g++-multilib \ - gcc-multilib \ gettext \ git \ gdb\ @@ -32,7 +42,7 @@ RUN apt-get update -y \ && rm -rf /var/lib/apt/lists/* \ && pip3 install pycryptodome -FROM CL0 AS CL1 +FROM cl0 AS cl1 ARG GPG_ERROR_VERSION=1.50 ARG GCRYPT_VERSION=1.11.0 RUN curl \ @@ -50,7 +60,7 @@ RUN curl \ && ./configure \ && make install -FROM CL1 AS CL2 +FROM cl1 AS cl2 ARG WOLFSSL_VERSION=5.6.0-stable RUN curl \ -LS https://github.com/wolfSSL/wolfssl/archive/v${WOLFSSL_VERSION}.zip \ diff --git a/support/scripts/docker_debug.sh b/support/scripts/docker_debug.sh index 5cbeb307..a7bf2a7b 100755 --- a/support/scripts/docker_debug.sh +++ b/support/scripts/docker_debug.sh @@ -9,5 +9,5 @@ SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd ) source $SCRIPT_DIR/env.sh echo "Start docker container to debug in..." -$DFLAGS -v $BASE_DIR:$BASE_DIR -w $BASE_DIR ivvitc/cryptolib bash +$DFLAGS -v $BASE_DIR:$BASE_DIR -w $BASE_DIR $DBOX bash echo "" diff --git a/support/scripts/env.sh b/support/scripts/env.sh index 3f157be1..4275d2db 100755 --- a/support/scripts/env.sh +++ b/support/scripts/env.sh @@ -8,3 +8,5 @@ SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd ) export BASE_DIR=$(cd `dirname $SCRIPT_DIR`/.. && pwd) export DFLAGS="docker run --rm -it" + +DBOX="ivvitc/cryptolib:20240814" diff --git a/support/scripts/internal_docker_build.sh b/support/scripts/internal_docker_build.sh index b2ae8ba7..3c86a21d 100755 --- a/support/scripts/internal_docker_build.sh +++ b/support/scripts/internal_docker_build.sh @@ -13,9 +13,9 @@ mkdir $BASE_DIR/build > /dev/null 2>&1 rm -r $BASE_DIR/build/internal/* > /dev/null 2>&1 mkdir $BASE_DIR/build/internal > /dev/null 2>&1 -#$DFLAGS -v $BASE_DIR:$BASE_DIR -w $BASE_DIR/build/internal ivvitc/cryptolib /bin/bash +#$DFLAGS -v $BASE_DIR:$BASE_DIR -w $BASE_DIR/build/internal $DBOX /bin/bash echo "Internal build and test..." -$DFLAGS -v $BASE_DIR:$BASE_DIR -w $BASE_DIR/build/internal ivvitc/cryptolib bash -c \ +$DFLAGS -v $BASE_DIR:$BASE_DIR -w $BASE_DIR/build/internal $DBOX bash -c \ "../../support/scripts/build_support.sh" echo "" diff --git a/support/scripts/kmc_docker_build.sh b/support/scripts/kmc_docker_build.sh index 31718968..e9e9e803 100755 --- a/support/scripts/kmc_docker_build.sh +++ b/support/scripts/kmc_docker_build.sh @@ -13,10 +13,10 @@ mkdir $BASE_DIR/build > /dev/null 2>&1 rm -r $BASE_DIR/build/kmc/* > /dev/null 2>&1 mkdir $BASE_DIR/build/kmc > /dev/null 2>&1 -#$DFLAGS -v $BASE_DIR:$BASE_DIR -w $BASE_DIR/build/kmc ivvitc/cryptolib /bin/bash +#$DFLAGS -v $BASE_DIR:$BASE_DIR -w $BASE_DIR/build/kmc $DBOX /bin/bash echo "KMC build and test..." # Note that the `KMC_MDB_DB` flag is not in use as docker compose will need configured to enable these tests -$DFLAGS -v $BASE_DIR:$BASE_DIR -w $BASE_DIR/build/kmc ivvitc/cryptolib bash -c \ +$DFLAGS -v $BASE_DIR:$BASE_DIR -w $BASE_DIR/build/kmc $DBOX bash -c \ "../../support/scripts/build_kmc.sh" echo "" diff --git a/support/scripts/wolf_docker_build.sh b/support/scripts/wolf_docker_build.sh index 45bc5efb..f8dbfdac 100755 --- a/support/scripts/wolf_docker_build.sh +++ b/support/scripts/wolf_docker_build.sh @@ -13,9 +13,9 @@ mkdir $BASE_DIR/build > /dev/null 2>&1 rm -r $BASE_DIR/build/wolf/* > /dev/null 2>&1 mkdir $BASE_DIR/build/wolf > /dev/null 2>&1 -#$DFLAGS -v $BASE_DIR:$BASE_DIR -w $BASE_DIR/build/wolf ivvitc/cryptolib /bin/bash +#$DFLAGS -v $BASE_DIR:$BASE_DIR -w $BASE_DIR/build/wolf $DBOX /bin/bash echo "Wolf build and test..." -$DFLAGS -v $BASE_DIR:$BASE_DIR -w $BASE_DIR/build/wolf ivvitc/cryptolib bash -c \ +$DFLAGS -v $BASE_DIR:$BASE_DIR -w $BASE_DIR/build/wolf $DBOX bash -c \ "../../support/scripts/build_wolf.sh" echo "" From 55b06ee3d7a442bbae9cd9aa5640d1ebaeff2214 Mon Sep 17 00:00:00 2001 From: "Lucas, John P." Date: Wed, 14 Aug 2024 10:06:18 -0400 Subject: [PATCH 3/3] [nasa/cryptolib#262] Added additional flags to docker run command; --- support/scripts/env.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/support/scripts/env.sh b/support/scripts/env.sh index 4275d2db..b469f37b 100755 --- a/support/scripts/env.sh +++ b/support/scripts/env.sh @@ -7,6 +7,7 @@ SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd ) export BASE_DIR=$(cd `dirname $SCRIPT_DIR`/.. && pwd) -export DFLAGS="docker run --rm -it" + +DFLAGS="docker run --rm -it -v /etc/passwd:/etc/passwd:ro -v /etc/group:/etc/group:ro -u $(id -u $(stat -c '%U' $SCRIPT_DIR/env.sh)):$(getent group $(stat -c '%G' $SCRIPT_DIR/env.sh) | cut -d: -f3)" DBOX="ivvitc/cryptolib:20240814"