Skip to content

Commit

Permalink
Merge pull request #270 from #262
Browse files Browse the repository at this point in the history
[#262] Versioned docker container and added top level Makefile
  • Loading branch information
jlucas9 authored Aug 15, 2024
2 parents 29abebd + 55b06ee commit 853fb5d
Show file tree
Hide file tree
Showing 7 changed files with 63 additions and 15 deletions.
35 changes: 35 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -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
24 changes: 17 additions & 7 deletions support/Dockerfile
Original file line number Diff line number Diff line change
@@ -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 \
Expand All @@ -15,8 +27,6 @@ RUN apt-get update -y \
ca-certificates \
cmake \
curl \
g++-multilib \
gcc-multilib \
gettext \
git \
gdb\
Expand All @@ -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 \
Expand All @@ -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 \
Expand Down
2 changes: 1 addition & 1 deletion support/scripts/docker_debug.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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 ""
5 changes: 4 additions & 1 deletion support/scripts/env.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +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"
4 changes: 2 additions & 2 deletions support/scripts/internal_docker_build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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 ""
4 changes: 2 additions & 2 deletions support/scripts/kmc_docker_build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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 ""
4 changes: 2 additions & 2 deletions support/scripts/wolf_docker_build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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 ""

0 comments on commit 853fb5d

Please sign in to comment.