From b3b0bd94cb734e76cd93cdce87945387f3475d96 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mois=C3=A9s=20Guimar=C3=A3es?= Date: Wed, 13 Sep 2017 20:31:11 -0300 Subject: [PATCH] adds alpine support --- global-config.sh => VERSION | 0 alpine/dev/Dockerfile | 55 +++++++++++++++++++++ alpine/lib/Dockerfile | 55 +++++++++++++++++++++ alpine/test/Dockerfile | 62 ++++++++++++++++++++++++ build-examples.sh | 91 +++++++++++++++++++++++++++++++++++ examples/Dockerfile | 34 +++++++++++++ examples/docker-entrypoint.sh | 14 ++++++ 7 files changed, 311 insertions(+) rename global-config.sh => VERSION (100%) mode change 100755 => 100644 create mode 100644 alpine/dev/Dockerfile create mode 100644 alpine/lib/Dockerfile create mode 100644 alpine/test/Dockerfile create mode 100755 build-examples.sh create mode 100644 examples/Dockerfile create mode 100755 examples/docker-entrypoint.sh diff --git a/global-config.sh b/VERSION old mode 100755 new mode 100644 similarity index 100% rename from global-config.sh rename to VERSION diff --git a/alpine/dev/Dockerfile b/alpine/dev/Dockerfile new file mode 100644 index 0000000..2f19e87 --- /dev/null +++ b/alpine/dev/Dockerfile @@ -0,0 +1,55 @@ +# 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_VERSION=3.12.0-stable +FROM alpine + +ARG WOLFSSL_VERSION + +RUN set -eux \ + # installing deps + && apk add --no-cache --virtual .build-deps \ + autoconf \ + automake \ + g++ \ + libtool \ + make \ + openssl \ + + # downloading source files + && wget https://github.com/wolfSSL/wolfssl/archive/v${WOLFSSL_VERSION}.zip \ + && unzip v${WOLFSSL_VERSION}.zip \ + + # building and installing wolfssl + && cd wolfssl-${WOLFSSL_VERSION} \ + && ./autogen.sh \ + && ./configure \ + --enable-singlethreaded \ + --disable-dependency-tracking \ + --enable-sha224 \ + --enable-distro \ + --disable-silent-rules \ + --disable-examples \ + && make \ + && make install \ + && cd .. \ + + # cleanup + && rm -r wolfssl-${WOLFSSL_VERSION} \ + && rm v${WOLFSSL_VERSION}.zip \ + && apk del .build-deps diff --git a/alpine/lib/Dockerfile b/alpine/lib/Dockerfile new file mode 100644 index 0000000..9b5e829 --- /dev/null +++ b/alpine/lib/Dockerfile @@ -0,0 +1,55 @@ +# 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_VERSION=3.12.0-stable +FROM alpine + +ARG WOLFSSL_VERSION + +RUN set -eux \ + # installing deps + && apk add --no-cache --virtual .build-deps \ + autoconf \ + automake \ + g++ \ + libtool \ + make \ + openssl \ + + # downloading source files + && wget https://github.com/wolfSSL/wolfssl/archive/v${WOLFSSL_VERSION}.zip \ + && unzip v${WOLFSSL_VERSION}.zip \ + + # building and installing wolfssl + && cd wolfssl-${WOLFSSL_VERSION} \ + && ./autogen.sh \ + && ./configure \ + --enable-singlethreaded \ + --disable-dependency-tracking \ + --enable-sha224 \ + --enable-distro \ + --disable-silent-rules \ + --disable-examples \ + && make \ + && make install-exec \ + && cd .. \ + + # cleanup + && rm -r wolfssl-${WOLFSSL_VERSION} \ + && rm v${WOLFSSL_VERSION}.zip \ + && apk del .build-deps diff --git a/alpine/test/Dockerfile b/alpine/test/Dockerfile new file mode 100644 index 0000000..bdea3e4 --- /dev/null +++ b/alpine/test/Dockerfile @@ -0,0 +1,62 @@ +# 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_VERSION=3.12.0-stable +FROM alpine + +# install dependencies +RUN set -eux \ + && apk add --no-cache --virtual .deps \ + autoconf \ + automake \ + g++ \ + libtool \ + make \ + openssl + +ARG WOLFSSL_VERSION + +# download source files +RUN set -eux \ + && wget https://github.com/wolfSSL/wolfssl/archive/v${WOLFSSL_VERSION}.zip \ + && unzip v${WOLFSSL_VERSION}.zip \ + && rm v${WOLFSSL_VERSION}.zip + +# build and test wolfssl +RUN set -eux \ + && cd wolfssl-${WOLFSSL_VERSION} \ + && ./autogen.sh \ + && ./configure \ + --enable-singlethreaded \ + --disable-dependency-tracking \ + --enable-sha224 \ + --enable-distro \ + --disable-silent-rules \ + && make \ + && make check + +# create example 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/build-examples.sh b/build-examples.sh new file mode 100755 index 0000000..d1724c0 --- /dev/null +++ b/build-examples.sh @@ -0,0 +1,91 @@ +#!/bin/sh +# +# Docker examples builder +# +# 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 VERSION + +function usage() +{ + echo "wolfSSL Docker examples builder" + echo "" + echo "./build-examples.sh TARGET_OS" + echo "\t-h --help prints this help message" + echo "\tTARGET_OS one of: alpine, centos, debian or ubuntu" + 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 + ;; + -*) + echo "ERROR: unknown parameter \"$PARAM\"" + usage + exit 1 + ;; + *) + if [[ "$PARAM" =~ ^(alpine|centos|debian|ubuntu)$ ]]; then + TARGET_OS=$PARAM + else + echo "ERROR: unknown target OS \"$PARAM\"" + usage + exit 1 + fi + ;; + esac + shift +done + +if [[ "$TARGET_OS" == "" ]]; then + usage + exit 1 +fi + +echo "Building docker examples using wolfssl:$TARGET_OS\n" + +docker build \ + -t wolfssl:$TARGET_OS-lib \ + --build-arg WOLFSSL_VERSION=$WOLFSSL_VERSION \ + $TARGET_OS/lib + +docker build \ + -t wolfssl:$TARGET_OS-test \ + --build-arg WOLFSSL_VERSION=$WOLFSSL_VERSION \ + $TARGET_OS/test + +docker run \ + --rm \ + --entrypoint cat \ + wolfssl:$TARGET_OS-test \ + /wolfssl/examples.tar.gz \ + > examples/examples.tar.gz + +docker build \ + -t wolfssl:$TARGET_OS-examples \ + --build-arg BASE_IMAGE=$TARGET_OS-lib \ + examples + +rm examples/examples.tar.gz + diff --git a/examples/Dockerfile b/examples/Dockerfile new file mode 100644 index 0000000..ebd93f7 --- /dev/null +++ b/examples/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 BASE_IMAGE=latest +FROM wolfssl:$BASE_IMAGE + +WORKDIR /wolfssl + +EXPOSE 11111 + +ADD examples.tar.gz /wolfssl + +COPY docker-entrypoint.sh /wolfssl/docker-entrypoint.sh + +ENTRYPOINT ["/wolfssl/docker-entrypoint.sh"] + +CMD ["sh"] \ No newline at end of file diff --git a/examples/docker-entrypoint.sh b/examples/docker-entrypoint.sh new file mode 100755 index 0000000..4ba9d7b --- /dev/null +++ b/examples/docker-entrypoint.sh @@ -0,0 +1,14 @@ +#!/bin/sh +set -e + +echo "Container's IP address: `awk 'END{print $1}' /etc/hosts`" + +if [ "$1" = 'server' ]; then + sh examples/server/$@ -bi +else + if [ "$1" = 'client' ]; then + sh examples/client/$@ + else + exec "$@" + fi +fi \ No newline at end of file