From 5722e6a42180fb0ba8e08f72a9a4c26857907b50 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mois=C3=A9s=20Guimar=C3=A3es?= Date: Wed, 13 Sep 2017 12:50:58 -0300 Subject: [PATCH] adds ubuntu support --- debian/from-source.dockerfile | 2 +- ubuntu/docker-build.sh | 86 +++++++++++++++++++++++ ubuntu/example/bin-example.dockerfile | 34 +++++++++ ubuntu/example/docker-build-examples.sh | 46 ++++++++++++ ubuntu/example/docker-entrypoint.sh | 14 ++++ ubuntu/example/example-builder.dockerfile | 70 ++++++++++++++++++ ubuntu/from-aptitude.dockerfile | 43 ++++++++++++ ubuntu/from-source.dockerfile | 73 +++++++++++++++++++ 8 files changed, 367 insertions(+), 1 deletion(-) create mode 100755 ubuntu/docker-build.sh create mode 100644 ubuntu/example/bin-example.dockerfile create mode 100755 ubuntu/example/docker-build-examples.sh create mode 100755 ubuntu/example/docker-entrypoint.sh create mode 100644 ubuntu/example/example-builder.dockerfile create mode 100644 ubuntu/from-aptitude.dockerfile create mode 100644 ubuntu/from-source.dockerfile diff --git a/debian/from-source.dockerfile b/debian/from-source.dockerfile index f60b932..e89cf22 100644 --- a/debian/from-source.dockerfile +++ b/debian/from-source.dockerfile @@ -61,8 +61,8 @@ RUN set -eux \ --disable-dependency-tracking \ --enable-sha224 \ --enable-distro \ - --disable-examples \ --disable-silent-rules \ + --disable-examples \ && make \ && make ${WOLFSSL_MAKE_INSTALL} \ && ldconfig \ diff --git a/ubuntu/docker-build.sh b/ubuntu/docker-build.sh new file mode 100755 index 0000000..ddf8ec2 --- /dev/null +++ b/ubuntu/docker-build.sh @@ -0,0 +1,86 @@ +#!/bin/sh +# +# Copyright (C) 2006-2017 wolfSSL Inc. +# +# This file is part of wolfSSL. +# +# wolfSSL is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# wolfSSL is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335, USA + +source ../global-config.sh + +# default building params +WOLFSSL_SOURCE="sid" +WOLFSSL_INSTALL="bin" +WOLFSSL_PACKAGES="libwolfssl12/sid" +WOLFSSL_MAKE_INSTALL="install-exec" + +function usage() +{ + echo "wolfSSL Docker image builder" + echo "" + echo "./docker_build.sh" + echo "\t-h --help prints this help message" + echo "\t--with-dev installs dev files" + echo "\t--from-src installs wolfssl from source files" + echo "" +} + +while [ "$1" != "" ]; do + PARAM=`echo $1 | awk -F= '{print $1}'` + VALUE=`echo $1 | awk -F= '{print $2}'` + case $PARAM in + -h | --help) + usage + exit + ;; + --with-dev) + WOLFSSL_INSTALL="dev" + WOLFSSL_MAKE_INSTALL="install" + WOLFSSL_PACKAGES=$WOLFSSL_PACKAGES" libwolfssl-dev/sid" + ;; + --from-src) + WOLFSSL_SOURCE="src" + ;; + *) + echo "ERROR: unknown parameter \"$PARAM\"" + usage + exit 1 + ;; + esac + shift +done + +WOLFSSL_DOCKER_TAG=$WOLFSSL_SOURCE-$WOLFSSL_INSTALL + +if [ "$WOLFSSL_SOURCE" == "sid" ]; then + echo "Building docker image using packages from Sid"; + echo "Installing the following wolfssl packages: "$WOLFSSL_PACKAGES; + echo ; + docker build \ + -t wolfssl/ubuntu:$WOLFSSL_DOCKER_TAG \ + -f from-aptitude.dockerfile \ + --build-arg WOLFSSL_PACKAGES="$WOLFSSL_PACKAGES" \ + .; +else + echo "Building docker image using wolfSSL-$WOLFSSL_VERSION source files"; + echo "Using the following wolfssl make instruction: "$WOLFSSL_MAKE_INSTALL; + echo ; + docker build \ + -t wolfssl/ubuntu:$WOLFSSL_DOCKER_TAG \ + -f from-source.dockerfile \ + --build-arg WOLFSSL_VERSION="$WOLFSSL_VERSION" \ + --build-arg WOLFSSL_MAKE_INSTALL="$WOLFSSL_MAKE_INSTALL" \ + .; +fi \ No newline at end of file diff --git a/ubuntu/example/bin-example.dockerfile b/ubuntu/example/bin-example.dockerfile new file mode 100644 index 0000000..bba56ab --- /dev/null +++ b/ubuntu/example/bin-example.dockerfile @@ -0,0 +1,34 @@ +# sid-bin-test.dockerfile +# +# Copyright (C) 2006-2017 wolfSSL Inc. +# +# This file is part of wolfSSL. +# +# wolfSSL is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# wolfSSL is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335, USA + +ARG WOLFSSL_UBUNTU_TAG=latest +FROM wolfssl/ubuntu:$WOLFSSL_UBUNTU_TAG + +WORKDIR /wolfssl + +EXPOSE 11111 + +ADD examples.tar.gz /wolfssl + +COPY docker-entrypoint.sh /wolfssl/docker-entrypoint.sh + +ENTRYPOINT ["/wolfssl/docker-entrypoint.sh"] + +CMD ["bash"] \ No newline at end of file diff --git a/ubuntu/example/docker-build-examples.sh b/ubuntu/example/docker-build-examples.sh new file mode 100755 index 0000000..b187bf7 --- /dev/null +++ b/ubuntu/example/docker-build-examples.sh @@ -0,0 +1,46 @@ +#!/bin/sh +# +# Docker examples builder (docker-build-examples.sh) +# +# Copyright (C) 2006-2017 wolfSSL Inc. +# +# This file is part of wolfSSL. +# +# wolfSSL is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# wolfSSL is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335, USA + +source ../../global-config.sh + +TAGS="sid-bin src-bin" + +docker build \ + -t wolfssl/ubuntu/example-builder \ + -f example-builder.dockerfile \ + --build-arg WOLFSSL_VERSION=$WOLFSSL_VERSION \ + . + +docker run \ + --rm \ + --entrypoint cat \ + wolfssl/ubuntu/example-builder \ + /wolfssl/examples.tar.gz \ + > examples.tar.gz + +for TAG in $TAGS; do + docker build \ + -t wolfssl/ubuntu/example:$TAG \ + -f bin-example.dockerfile \ + --build-arg WOLFSSL_UBUNTU_TAG=$TAG \ + . +done diff --git a/ubuntu/example/docker-entrypoint.sh b/ubuntu/example/docker-entrypoint.sh new file mode 100755 index 0000000..5f96378 --- /dev/null +++ b/ubuntu/example/docker-entrypoint.sh @@ -0,0 +1,14 @@ +#!/bin/bash +set -e + +echo "Container's IP address: `awk 'END{print $1}' /etc/hosts`" + +if [ "$1" = 'server' ]; then + ./examples/server/$@ -bi +else + if [ "$1" = 'client' ]; then + ./examples/client/$@ + else + exec "$@" + fi +fi \ No newline at end of file diff --git a/ubuntu/example/example-builder.dockerfile b/ubuntu/example/example-builder.dockerfile new file mode 100644 index 0000000..12df066 --- /dev/null +++ b/ubuntu/example/example-builder.dockerfile @@ -0,0 +1,70 @@ +# Dockerfile +# +# Copyright (C) 2006-2017 wolfSSL Inc. +# +# This file is part of wolfSSL. +# +# wolfSSL is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# wolfSSL is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335, USA + +FROM ubuntu + +# installing build deps +RUN set -eux \ + && buildDeps=' \ + autoconf \ + automake \ + ca-certificates \ + curl \ + g++ \ + libtool \ + make \ + unzip \ + ' \ + && apt-get update \ + && apt-get install -y --no-install-recommends $buildDeps \ + && rm -r /var/lib/apt/lists/* + +ARG WOLFSSL_VERSION + +# downloading source files +RUN set -eux \ + && curl \ + -LS https://github.com/wolfSSL/wolfssl/archive/v${WOLFSSL_VERSION}.zip \ + -o v${WOLFSSL_VERSION}.zip \ + && unzip v${WOLFSSL_VERSION}.zip \ + && rm v${WOLFSSL_VERSION}.zip + +# building and installing wolfssl +RUN set -eux \ + && cd wolfssl-${WOLFSSL_VERSION} \ + && ./autogen.sh \ + && ./configure \ + --disable-dependency-tracking \ + --enable-sha224 \ + --enable-distro \ + --disable-silent-rules \ + && make \ + && make check + +# create testing package +RUN set -eux \ + && mkdir /wolfssl \ + && tar -czvf /wolfssl/examples.tar.gz \ + -C /wolfssl-${WOLFSSL_VERSION} \ + examples/client/client \ + examples/server/server \ + examples/client/.libs \ + examples/server/.libs \ + certs diff --git a/ubuntu/from-aptitude.dockerfile b/ubuntu/from-aptitude.dockerfile new file mode 100644 index 0000000..8e55f63 --- /dev/null +++ b/ubuntu/from-aptitude.dockerfile @@ -0,0 +1,43 @@ +# Copyright (C) 2006-2017 wolfSSL Inc. +# +# This file is part of wolfSSL. +# +# wolfSSL is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# wolfSSL is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335, USA + +FROM ubuntu + +# activate WOLFSSL_INSTALLS arg after FROM +ARG WOLFSSL_PACKAGES + +# install wolfssl from sid +RUN set -eux \ + # adds required keys to install from sid + && gpg --keyserver pgpkeys.mit.edu --recv-key 8B48AD6246925553 \ + && gpg -a --export 8B48AD6246925553 | apt-key add - \ + && gpg --keyserver pgpkeys.mit.edu --recv-key 7638D0442B90D010 \ + && gpg -a --export 7638D0442B90D010 | apt-key add - \ + + # installs wolfssl from sid + && echo "deb http://ftp.it.debian.org/debian sid main contrib non-free" \ + > /etc/apt/sources.list.d/wolfssl.list \ + && apt-get update \ + && apt-get install -y ${WOLFSSL_PACKAGES} \ + + # cleanup + && rm -r /var/lib/apt/lists/* \ + && rm /etc/apt/sources.list.d/wolfssl.list \ + && apt-key del 8B48AD6246925553 \ + && apt-key del 7638D0442B90D010 \ + && rm -r /root/.gnupg diff --git a/ubuntu/from-source.dockerfile b/ubuntu/from-source.dockerfile new file mode 100644 index 0000000..8c48cc0 --- /dev/null +++ b/ubuntu/from-source.dockerfile @@ -0,0 +1,73 @@ +# Copyright (C) 2006-2017 wolfSSL Inc. +# +# This file is part of wolfSSL. +# +# wolfSSL is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# wolfSSL is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335, USA + +FROM ubuntu + +ARG WOLFSSL_VERSION + +ARG WOLFSSL_MAKE_INSTALL + +RUN set -eux \ + # installing build deps + && buildDeps=' \ + autoconf \ + automake \ + ca-certificates \ + curl \ + g++ \ + libtool \ + make \ + unzip \ + ' \ + && apt-get update \ + && apt-get install -y --no-install-recommends $buildDeps \ + && rm -r /var/lib/apt/lists/* \ + + # downloading source files + && curl \ + -LS https://github.com/wolfSSL/wolfssl/archive/v${WOLFSSL_VERSION}.zip \ + -o v${WOLFSSL_VERSION}.zip \ + && unzip v${WOLFSSL_VERSION}.zip \ + && rm v${WOLFSSL_VERSION}.zip \ + + # building and installing wolfssl + && cd wolfssl-${WOLFSSL_VERSION} \ + && ./autogen.sh \ + && ./configure \ + --build=x86_64-linux-gnu \ + --prefix=/usr \ + --includedir=\${prefix}/include \ + --mandir=\${prefix}/share/man \ + --infodir=\${prefix}/share/info \ + --sysconfdir=/etc \ + --localstatedir=/var \ + --libdir=\${prefix}/lib/x86_64-linux-gnu \ + --libexecdir=\${prefix}/lib/x86_64-linux-gnu \ + --disable-dependency-tracking \ + --enable-sha224 \ + --enable-distro \ + --disable-silent-rules \ + --disable-examples \ + && make \ + && make ${WOLFSSL_MAKE_INSTALL} \ + && ldconfig \ + + # cleaning building deps + && cd .. \ + && rm -r wolfssl-${WOLFSSL_VERSION} \ + && apt-get purge -y --auto-remove $buildDeps