Merge pull request #5895 from bandi13/addDocker

Add docker
This commit is contained in:
David Garske
2022-12-22 17:19:43 -08:00
committed by GitHub
5 changed files with 41 additions and 0 deletions

11
Docker/Dockerfile Normal file
View File

@ -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}

13
Docker/README.md Normal file
View File

@ -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.

7
Docker/include.am Normal file
View File

@ -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

9
Docker/run.sh Executable file
View File

@ -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 $?"

View File

@ -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