From 2ef83e142f467ccbdc0ff54bf23713f0a58e5c93 Mon Sep 17 00:00:00 2001 From: Andras Fekete Date: Thu, 28 Sep 2023 13:27:07 -0400 Subject: [PATCH 1/4] Update buildAndPush.sh and README.md --- Docker/README.md | 5 ++++- Docker/buildAndPush.sh | 30 +++++++++++++++++++++++++----- 2 files changed, 29 insertions(+), 6 deletions(-) diff --git a/Docker/README.md b/Docker/README.md index bb4ba3eb9..8cb3d603a 100644 --- a/Docker/README.md +++ b/Docker/README.md @@ -3,6 +3,9 @@ This is a Docker environment for compiling, testing and running WolfSSL. Use `ru When the compilation and tests succeed, you will be dropped in to a shell environment within the container. This can be useful to build other things within the environment. Additional tests can be run as well as debugging of code. +# Docker Hub +These images are also uploaded to the wolfSSL's [Docker Hub page](https://hub.docker.com/orgs/wolfssl/repositories). There is a convenience script here `buildAndPush.sh` that will create the appropriate containers and push them to the repo. + # FAQ ## permission denied while trying to connect to the Docker daemon socket at unix:///var/run/docker.sock You need to be added to the `docker` group to run Docker containers. Run `sudo usermod -aG docker $USER`. You may need to restart the Docker daemon. @@ -10,4 +13,4 @@ You need to be added to the `docker` group to run Docker containers. Run `sudo u ## Unable to access symlinked files outside of WolfSSL The volume mounted in the Docker container needs to have all files that your compilation will need. To solve this, you have a couple options: 1. Change the `WOLFSSL_DIR` variable in the `run.sh` to one higher up (by adding `/..` to the path). Then update the `docker build` to include the correct path to the Dockerfile and the `docker run` argument to the working directory (`-w`) to the WolfSSL source directory -2. Move the external repository to within the WolfSSL directory. For example create an `external` folder which has your files. This route may have complications when stashing Git work. \ No newline at end of file +2. Move the external repository to within the WolfSSL directory. For example create an `external` folder which has your files. This route may have complications when stashing Git work. diff --git a/Docker/buildAndPush.sh b/Docker/buildAndPush.sh index 84813ab8a..1973d43f0 100755 --- a/Docker/buildAndPush.sh +++ b/Docker/buildAndPush.sh @@ -5,13 +5,33 @@ if [ "${DOCKER_BASE_IMAGE}" != "" ]; then DOCKER_BUILD_OPTIONS+=" --build-arg DOCKER_BASE_IMAGE=${DOCKER_BASE_IMAGE}" fi +NUM_FAILURES=0 + CUR_DATE=$(date -u +%F) echo "Building wolfssl/wolfssl-builder:${CUR_DATE} as ${DOCKER_BUILD_OPTIONS}" docker build -t wolfssl/wolfssl-builder:${CUR_DATE} ${DOCKER_BUILD_OPTIONS} "${WOLFSSL_DIR}/Docker" && \ - docker push wolfssl/wolfssl-builder:${CUR_DATE} && \ docker tag wolfssl/wolfssl-builder:${CUR_DATE} wolfssl/wolfssl-builder:latest && \ - docker push wolfssl/wolfssl-builder:latest && \ docker build --build-arg DOCKER_BASE_IMAGE=wolfssl/wolfssl-builder:${CUR_DATE} -t wolfssl/testing-cross-compiler:${CUR_DATE} "${WOLFSSL_DIR}/Docker" -f Dockerfile.cross-compiler && \ - docker push wolfssl/testing-cross-compiler:${CUR_DATE} && \ - docker tag wolfssl/testing-cross-compiler:${CUR_DATE} wolfssl/testing-cross-compiler:latest && \ - docker push wolfssl/testing-cross-compiler:latest + docker tag wolfssl/testing-cross-compiler:${CUR_DATE} wolfssl/testing-cross-compiler:latest + +if [ $? -eq 0 ]; then + echo "Pushing containers to DockerHub" + docker push wolfssl/wolfssl-builder:${CUR_DATE} && docker push wolfssl/wolfssl-builder:latest && \ + docker push wolfssl/testing-cross-compiler:${CUR_DATE} && docker push wolfssl/testing-cross-compiler:latest +else + echo "Warning: Build wolfssl/wolfssl-builder failed. Continuing" + ((NUM_FAILURES++)) +fi + +echo "Building wolfssl/wolfCLU:${CUR_DATE}" +docker build --pull --build-arg DUMMY=${CUR_DATE} -t wolfssl/wolfclu:${CUR_DATE} "${WOLFSSL_DIR}/Docker/wolfCLU" && \ + docker tag wolfssl/wolfclu:${CUR_DATE} wolfssl/wolfclu:latest +if [ $? -eq 0 ]; then + echo "Pushing containers to DockerHub" + docker push wolfssl/wolfclu:${CUR_DATE} && docker push wolfssl/wolfclu:latest +else + echo "Warning: Build wolfssl/wolfclu failed. Continuing" + ((NUM_FAILURES++)) +fi + +echo "Script completed in $SECONDS seconds. Had $NUM_FAILURES failures." From 5e1bd8174ca26a4ff67c10a9c3da4a800a56991b Mon Sep 17 00:00:00 2001 From: Andras Fekete Date: Thu, 28 Sep 2023 13:55:38 -0400 Subject: [PATCH 2/4] Push multi-platform wolfCLU to DockerHub --- Docker/buildAndPush.sh | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/Docker/buildAndPush.sh b/Docker/buildAndPush.sh index 1973d43f0..feca081b5 100755 --- a/Docker/buildAndPush.sh +++ b/Docker/buildAndPush.sh @@ -24,12 +24,9 @@ else fi echo "Building wolfssl/wolfCLU:${CUR_DATE}" -docker build --pull --build-arg DUMMY=${CUR_DATE} -t wolfssl/wolfclu:${CUR_DATE} "${WOLFSSL_DIR}/Docker/wolfCLU" && \ - docker tag wolfssl/wolfclu:${CUR_DATE} wolfssl/wolfclu:latest -if [ $? -eq 0 ]; then - echo "Pushing containers to DockerHub" - docker push wolfssl/wolfclu:${CUR_DATE} && docker push wolfssl/wolfclu:latest -else +docker buildx build --pull --push --build-arg DUMMY=${CUR_DATE} -t wolfssl/wolfclu:${CUR_DATE} --platform=linux/amd64,linux/arm64,linux/arm/v7 "${WOLFSSL_DIR}/Docker/wolfCLU" && \ +docker buildx build --pull --push --build-arg DUMMY=${CUR_DATE} -t wolfssl/wolfclu:latest --platform=linux/amd64,linux/arm64,linux/arm/v7 "${WOLFSSL_DIR}/Docker/wolfCLU" +if [ $? -ne 0 ]; then echo "Warning: Build wolfssl/wolfclu failed. Continuing" ((NUM_FAILURES++)) fi From 93358f140268a21e87e33a15385e1f9b6e81a785 Mon Sep 17 00:00:00 2001 From: Andras Fekete Date: Thu, 28 Sep 2023 13:59:04 -0400 Subject: [PATCH 3/4] Define WOLFSSL_DIR --- Docker/buildAndPush.sh | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Docker/buildAndPush.sh b/Docker/buildAndPush.sh index feca081b5..d66e2c848 100755 --- a/Docker/buildAndPush.sh +++ b/Docker/buildAndPush.sh @@ -1,5 +1,8 @@ #!/bin/bash +# Assume we're in wolfssl/Docker +WOLFSSL_DIR=$(builtin cd ${BASH_SOURCE%/*}/..; pwd) + DOCKER_BUILD_OPTIONS="$1" if [ "${DOCKER_BASE_IMAGE}" != "" ]; then DOCKER_BUILD_OPTIONS+=" --build-arg DOCKER_BASE_IMAGE=${DOCKER_BASE_IMAGE}" From 005346d9ecd6246e88ae87bd0b059ba6caf08159 Mon Sep 17 00:00:00 2001 From: Andras Fekete Date: Thu, 28 Sep 2023 14:45:51 -0400 Subject: [PATCH 4/4] Fix entrypoint --- Docker/wolfCLU/Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Docker/wolfCLU/Dockerfile b/Docker/wolfCLU/Dockerfile index deb388d8e..4c07e853b 100644 --- a/Docker/wolfCLU/Dockerfile +++ b/Docker/wolfCLU/Dockerfile @@ -21,6 +21,6 @@ USER root COPY --from=BUILDER /usr/local/lib/libwolfssl.so /usr/local/lib/ COPY --from=BUILDER /usr/local/bin/wolfssl* /usr/local/bin/ RUN ldconfig -CMD ["/usr/local/bin/wolfssl"] +ENTRYPOINT ["/usr/local/bin/wolfssl"] LABEL org.opencontainers.image.source=https://github.com/wolfssl/wolfssl LABEL org.opencontainers.image.description="Simple wolfCLU in a container"