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..d66e2c848 100755 --- a/Docker/buildAndPush.sh +++ b/Docker/buildAndPush.sh @@ -1,17 +1,37 @@ #!/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}" 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 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 + +echo "Script completed in $SECONDS seconds. Had $NUM_FAILURES failures." 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"