adds alpine support

master
Moisés Guimarães 2017-09-13 20:31:11 -03:00
parent 5722e6a421
commit b3b0bd94cb
7 changed files with 311 additions and 0 deletions

0
global-config.sh → VERSION 100755 → 100644
View File

View File

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

View File

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

View File

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

91
build-examples.sh 100755
View File

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

View File

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

View File

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