From 2ef83e142f467ccbdc0ff54bf23713f0a58e5c93 Mon Sep 17 00:00:00 2001 From: Andras Fekete Date: Thu, 28 Sep 2023 13:27:07 -0400 Subject: [PATCH] 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."