diff --git a/Docker/Dockerfile b/Docker/Dockerfile new file mode 100644 index 000000000..36cc30535 --- /dev/null +++ b/Docker/Dockerfile @@ -0,0 +1,11 @@ +ARG DOCKER_BASE_IMAGE=ubuntu:22.04 +FROM $DOCKER_BASE_IMAGE + +RUN DEBIAN_FRONTEND=noninteractive apt update && apt install -y build-essential autoconf libtool + +ARG USER=docker +ARG UID=1000 +ARG GID=1000 +RUN groupadd -f -g ${GID} docker && useradd -ms /bin/bash ${USER} -u ${UID} -g ${GID} + +USER ${UID}:${GID} \ No newline at end of file diff --git a/Docker/README.md b/Docker/README.md new file mode 100644 index 000000000..8855aba30 --- /dev/null +++ b/Docker/README.md @@ -0,0 +1,13 @@ +# Overview +This is a simple Docker environment for compiling and running WolfSSL. Use `run.sh` to build everything (Docker container, WolfSSL, etc.). This script takes in arguments that can be passed to `./configure`. For example: `run.sh --enable-all` + +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. + +# 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. + +## 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 diff --git a/Docker/include.am b/Docker/include.am new file mode 100644 index 000000000..c6de20108 --- /dev/null +++ b/Docker/include.am @@ -0,0 +1,7 @@ +# vim:ft=automake +# included from Top Level Makefile.am +# All paths should be given relative to the root + +EXTRA_DIST+= Docker/Dockerfile +EXTRA_DIST+= Docker/run.sh +EXTRA_DIST+= Docker/README.md \ No newline at end of file diff --git a/Docker/run.sh b/Docker/run.sh new file mode 100755 index 000000000..c1d4e2489 --- /dev/null +++ b/Docker/run.sh @@ -0,0 +1,9 @@ +echo "Running with \"${@}\"..." + +# Assume we're in wolfssl/Docker +WOLFSSL_DIR=$(builtin cd ${BASH_SOURCE%/*}/..; pwd) + +docker build -t wolfssl --build-arg UID=$(id -u) --build-arg GID=$(id -g) ${WOLFSSL_DIR}/Docker && \ +docker run -it -v ${WOLFSSL_DIR}:/tmp/wolfssl -w /tmp/wolfssl wolfssl /bin/bash -c "./autogen.sh && ./configure $(echo ${@}) && make && ./testsuite/testsuite.test" && \ +docker run -it -v ${WOLFSSL_DIR}:/tmp/wolfssl -w /tmp/wolfssl wolfssl /bin/bash +echo "Exited with error code $?" diff --git a/Makefile.am b/Makefile.am index f2231a6bc..917832e40 100644 --- a/Makefile.am +++ b/Makefile.am @@ -161,6 +161,7 @@ include cyassl/include.am include wolfssl/include.am include certs/include.am include doc/include.am +include Docker/include.am include src/include.am include support/include.am