From 98f8ff45b2a8edcf3e339b0ab1e504a0d4a3c071 Mon Sep 17 00:00:00 2001 From: Tomohisa Kusano Date: Thu, 29 Mar 2018 15:25:29 -0700 Subject: [PATCH] handle multiple base images --- Dockerfile | 42 +++++++++++---------------------------- Dockerfile.debian | 37 ++++++++++++++++++++++++++++++++++ copyables/build-centos.sh | 34 +++++++++++++++++++++++++++++++ copyables/build-debian.sh | 39 ++++++++++++++++++++++++++++++++++++ 4 files changed, 122 insertions(+), 30 deletions(-) create mode 100644 Dockerfile.debian create mode 100644 copyables/build-centos.sh create mode 100644 copyables/build-debian.sh diff --git a/Dockerfile b/Dockerfile index 5e1c62b2..bc2802bc 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,4 @@ -FROM debian:9-slim +FROM alpine:3.7 as prep LABEL maintainer="Tomohisa Kusano " \ contributors="Ian Neubert ; Ky-Anh Huynh ; Max Kuchin ; maltalex " @@ -6,39 +6,21 @@ LABEL maintainer="Tomohisa Kusano " \ ENV BUILD_VERSION=4.25-9656-rtm \ SHA256_SUM=c5a1791d69dc6d1c53fb574a3ce709707338520be797acbeac0a631c96c68330 -#install wget -RUN apt-get update \ - && apt-get install -y wget \ - && rm -rf /var/lib/apt/lists/* - -#Get, extract and build softether RUN wget https://github.com/SoftEtherVPN/SoftEtherVPN_Stable/archive/v${BUILD_VERSION}.tar.gz \ - && echo "${SHA256_SUM} v${BUILD_VERSION}.tar.gz" | sha256sum -c --strict --quiet \ - && tar xf v${BUILD_VERSION}.tar.gz && rm v${BUILD_VERSION}.tar.gz \ - && apt-get update && apt-get install -y --no-install-recommends \ - build-essential \ - libreadline7 \ - libreadline-dev \ - libssl1.1 \ - libssl-dev \ - libncurses5 \ - libncurses5-dev \ - zlib1g \ - zlib1g-dev \ - iptables \ - unzip \ - && cd SoftEtherVPN_Stable-${BUILD_VERSION} && ./configure && make && make install \ - && cd / && rm -rf /SoftEtherVPN_Stable-${BUILD_VERSION} \ - && apt-get purge -y \ - build-essential \ - libreadline-dev \ - libssl-dev \ - lib32ncurses5-dev \ - zlib1g-dev \ - && apt-get -y autoremove && rm -rf /var/lib/apt/lists/* + && echo "${SHA256_SUM} v${BUILD_VERSION}.tar.gz" | sha256sum -c \ + && mkdir -p /usr/local/src \ + && tar -x -C /usr/local/src/ -f v${BUILD_VERSION}.tar.gz \ + && rm v${BUILD_VERSION}.tar.gz + +FROM centos:7 + +COPY --from=prep /usr/local/src /usr/local/src COPY copyables / +RUN /bin/bash /build-centos.sh \ + && /bin/rm /build-*.sh + RUN chmod +x /entrypoint.sh /gencert.sh \ && rm -rf /opt && ln -s /usr/vpnserver /opt \ && find /usr/bin/vpn* -type f ! -name vpnserver \ diff --git a/Dockerfile.debian b/Dockerfile.debian new file mode 100644 index 00000000..5e6d78eb --- /dev/null +++ b/Dockerfile.debian @@ -0,0 +1,37 @@ +FROM alpine:3.7 as prep + +LABEL maintainer="Tomohisa Kusano " \ + contributors="Ian Neubert ; Ky-Anh Huynh ; Max Kuchin ; maltalex " + +ENV BUILD_VERSION=4.25-9656-rtm \ + SHA256_SUM=c5a1791d69dc6d1c53fb574a3ce709707338520be797acbeac0a631c96c68330 + +RUN wget https://github.com/SoftEtherVPN/SoftEtherVPN_Stable/archive/v${BUILD_VERSION}.tar.gz \ + && echo "${SHA256_SUM} v${BUILD_VERSION}.tar.gz" | sha256sum -c \ + && mkdir -p /usr/local/src \ + && tar -x -C /usr/local/src/ -f v${BUILD_VERSION}.tar.gz \ + && rm v${BUILD_VERSION}.tar.gz + +FROM debian:9-slim + +COPY --from=prep /usr/local/src /usr/local/src + +COPY copyables / + +RUN /bin/bash /build-debian.sh \ + && /bin/rm /build-*.sh + +RUN chmod +x /entrypoint.sh /gencert.sh \ + && rm -rf /opt && ln -s /usr/vpnserver /opt \ + && find /usr/bin/vpn* -type f ! -name vpnserver \ + -exec bash -c 'ln -s {} /opt/$(basename {})' \; + +WORKDIR /usr/vpnserver/ + +VOLUME ["/usr/vpnserver/server_log/"] + +ENTRYPOINT ["/entrypoint.sh"] + +EXPOSE 500/udp 4500/udp 1701/tcp 1194/udp 5555/tcp + +CMD ["/usr/bin/vpnserver", "execsvc"] diff --git a/copyables/build-centos.sh b/copyables/build-centos.sh new file mode 100644 index 00000000..c545549f --- /dev/null +++ b/copyables/build-centos.sh @@ -0,0 +1,34 @@ +#!/bin/bash + +echo "clean_requirements_on_remove=1" >> /etc/yum.conf + +yum -y update \ + && yum -y install unzip \ + && yum -y groupinstall "Development Tools" \ + && yum -y install readline-devel ncurses-devel openssl-devel iptables sysvinit-tools + +# Build SoftEtherVPN + +cd /usr/local/src/SoftEtherVPN_Stable-* + +cp src/makefiles/linux_64bit.mak Makefile + +make + +make install + +cd / + +rm -rf /usr/local/src/SoftEtherVPN_Stable-* + +# Clean-up +# Keep iptables (for vpnserver) & sysvinit-tools (for pidof) + +yum -y remove readline-devel ncurses-devel openssl-devel \ + && yum -y groupremove "Development Tools" \ + && yum clean all + +rm -rf /var/log/* /var/cache/yum/* /var/lib/yum/* + +exit 0 + diff --git a/copyables/build-debian.sh b/copyables/build-debian.sh new file mode 100644 index 00000000..91dbca67 --- /dev/null +++ b/copyables/build-debian.sh @@ -0,0 +1,39 @@ +#!/bin/bash + +apt-get update + +apt-get install -y --no-install-recommends \ + build-essential \ + libreadline7 \ + libreadline-dev \ + libssl1.1 \ + libssl-dev \ + libncurses5 \ + libncurses5-dev \ + zlib1g \ + zlib1g-dev \ + iptables \ + unzip \ + +cd /usr/local/src/SoftEtherVPN_Stable-* + +./configure + +make + +make install + +cd / + +rm -rf /usr/local/src/SoftEtherVPN_Stable-* + +apt-get purge -y \ + build-essential \ + libreadline-dev \ + libssl-dev \ + lib32ncurses5-dev \ + zlib1g-dev + +apt-get -y autoremove + +rm -rf /var/lib/apt/lists/*