diff --git a/basic-runtimes.sh b/basic-runtimes.sh index 37641ae..f803d6e 100755 --- a/basic-runtimes.sh +++ b/basic-runtimes.sh @@ -4,15 +4,49 @@ set -e SOURCE_DIR=$(realpath $(dirname "${0}"))/basic-runtimes # Build basic Alpine image -mkdir -p /var/lib/lxc/build/alpine -wget https://github.com/gliderlabs/docker-alpine/raw/2bfe6510ee31d86cfeb2f37587f4cf866f28ffbc/versions/library-3.8/x86_64/rootfs.tar.xz -O - | tar xJf - -C /var/lib/lxc/build/rootfs +mkdir -p /var/lib/lxc/build +mkdir -p /var/lib/lxc/shared/alpine +wget https://github.com/gliderlabs/docker-alpine/raw/2bfe6510ee31d86cfeb2f37587f4cf866f28ffbc/versions/library-3.8/x86_64/rootfs.tar.xz -O - | tar xJf - -C /var/lib/lxc/shared/alpine +touch /var/lib/lxc/shared/alpine/etc/resolv.conf cp ${SOURCE_DIR}/var/lib/lxc/build/config /var/lib/lxc/build/config lxc-execute -n build -- /bin/sh -c 'apk --no-cache add s6' -# Build Docker images -docker build -t java ${SOURCE_DIR}/java -docker build -t php ${SOURCE_DIR}/php -docker build -t python2 ${SOURCE_DIR}/python2 -docker build -t python3 ${SOURCE_DIR}/python3 -docker build -t ruby ${SOURCE_DIR}/ruby -docker build -t tomcat ${SOURCE_DIR}/tomcat +# Build Java overlay +mkdir /var/lib/lxc/shared/java +sed -i 's|^lxc\.rootfs\.path.*|lxc.rootfs.path = overlay:/var/lib/lxc/shared/alpine:/var/lib/lxc/shared/java|' /var/lib/lxc/build/config +lxc-execute -n build -- /bin/sh -c 'apk --no-cache add openjdk8-jre-base' + +# Build PHP overlay +mkdir /var/lib/lxc/shared/php +sed -i 's|^lxc\.rootfs\.path.*|lxc.rootfs.path = overlay:/var/lib/lxc/shared/alpine:/var/lib/lxc/shared/php|' /var/lib/lxc/build/config +lxc-execute -n build -- /bin/sh -c 'apk --no-cache add nginx php7 php7-ctype php7-fpm php7-gd php7-json php7-mbstring php7-mcrypt php7-opcache php7-session' + +# Build libxml overlay +mkdir /var/lib/lxc/shared/libxml +sed -i 's|^lxc\.rootfs\.path.*|lxc.rootfs.path = overlay:/var/lib/lxc/shared/alpine:/var/lib/lxc/shared/libxml|' /var/lib/lxc/build/config +lxc-execute -n build -- /bin/sh -c 'apk --no-cache add libxml2 libxslt' + +# Build Python2 overlay +mkdir /var/lib/lxc/shared/python2 +sed -i 's|^lxc\.rootfs\.path.*|lxc.rootfs.path = overlay:/var/lib/lxc/shared/alpine:/var/lib/lxc/shared/libxml:/var/lib/lxc/shared/python2|' /var/lib/lxc/build/config +lxc-execute -n build -- /bin/sh -c 'apk --no-cache add python2' + +# Build Python3 overlay +mkdir /var/lib/lxc/shared/python3 +sed -i 's|^lxc\.rootfs\.path.*|lxc.rootfs.path = overlay:/var/lib/lxc/shared/alpine:/var/lib/lxc/shared/libxml:/var/lib/lxc/shared/python3|' /var/lib/lxc/build/config +lxc-execute -n build -- /bin/sh -c 'apk --no-cache add python3 && ln -s /usr/bin/python3 /usr/bin/python' + +# Build Ruby overlay +mkdir /var/lib/lxc/shared/ruby +sed -i 's|^lxc\.rootfs\.path.*|lxc.rootfs.path = overlay:/var/lib/lxc/shared/alpine:/var/lib/lxc/shared/ruby|' /var/lib/lxc/build/config +cp -p ${SOURCE_DIR}/ruby.sh /var/lib/lxc/shared/ruby/ruby.sh +lxc-execute -n build -- /ruby.sh +rm /var/lib/lxc/shared/ruby/ruby.sh + +# Build Tomcat overlay +mkdir /var/lib/lxc/shared/tomcat +sed -i 's|^lxc\.rootfs\.path.*|lxc.rootfs.path = overlay:/var/lib/lxc/shared/alpine:/var/lib/lxc/shared/java:/var/lib/lxc/shared/tomcat|' /var/lib/lxc/build/config +cp -p ${SOURCE_DIR}/tomcat.sh /var/lib/lxc/shared/tomcat/tomcat.sh +lxc-execute -n build -- /tomcat.sh +rm /var/lib/lxc/shared/tomcat/ruby.sh +cp -rp ${SOURCE_DIR}/tomcat/ /var/lib/lxc/shared/tomcat/ diff --git a/basic-runtimes/java/Dockerfile b/basic-runtimes/java/Dockerfile deleted file mode 100644 index e569a70..0000000 --- a/basic-runtimes/java/Dockerfile +++ /dev/null @@ -1,6 +0,0 @@ -FROM alpine -LABEL maintainer="Disassembler " - -RUN \ - # Install Java 1.8 JRE - apk --no-cache add openjdk8-jre-base diff --git a/basic-runtimes/php/Dockerfile b/basic-runtimes/php/Dockerfile deleted file mode 100644 index 396c8c5..0000000 --- a/basic-runtimes/php/Dockerfile +++ /dev/null @@ -1,6 +0,0 @@ -FROM alpine -LABEL maintainer="Disassembler " - -RUN \ - # Install PHP runtime - apk --no-cache add nginx php7 php7-ctype php7-fpm php7-gd php7-json php7-mbstring php7-mcrypt php7-opcache php7-session diff --git a/basic-runtimes/python2/Dockerfile b/basic-runtimes/python2/Dockerfile deleted file mode 100644 index 46e9da1..0000000 --- a/basic-runtimes/python2/Dockerfile +++ /dev/null @@ -1,10 +0,0 @@ -FROM alpine -LABEL maintainer="Disassembler " - -RUN \ - # Install XML libs - apk --no-cache add libxml2 libxslt - -RUN \ - # Install Python2 runtime - apk --no-cache add python2 diff --git a/basic-runtimes/python3/Dockerfile b/basic-runtimes/python3/Dockerfile deleted file mode 100644 index ffb1d6b..0000000 --- a/basic-runtimes/python3/Dockerfile +++ /dev/null @@ -1,11 +0,0 @@ -FROM alpine -LABEL maintainer="Disassembler " - -RUN \ - # Install XML libs - apk --no-cache add libxml2 libxslt - -RUN \ - # Install Python3 runtime - apk --no-cache add python3 \ - && ln -s /usr/bin/python3 /usr/bin/python diff --git a/basic-runtimes/ruby/Dockerfile b/basic-runtimes/ruby/Dockerfile deleted file mode 100644 index ce68ab7..0000000 --- a/basic-runtimes/ruby/Dockerfile +++ /dev/null @@ -1,33 +0,0 @@ -FROM alpine -LABEL maintainer="Disassembler " - -RUN \ - # Install Ruby runtime dependencies - apk --no-cache add gdbm libressl readline zlib - -RUN \ - # Install Ruby build dependencies - apk --no-cache add --virtual .deps build-base autoconf gdbm-dev libressl-dev linux-headers readline-dev zlib-dev \ - # Download and unpack Ruby - && wget http://cache.ruby-lang.org/pub/ruby/2.3/ruby-2.3.6.tar.xz -O ruby.tar.xz \ - && mkdir -p /usr/src/ruby \ - && tar -xJf ruby.tar.xz -C /usr/src/ruby --strip-components=1 \ - && rm ruby.tar.xz \ - && cd /usr/src/ruby \ - # Hackfix to suppress "Insecure world writable dir" warning - && sed -ni 'p;13a #define ENABLE_PATH_CHECK 0' file.c \ - # Configure compilation + hackfix to detect isnan/isinf macros - && autoconf \ - && ac_cv_func_isnan=yes ac_cv_func_isinf=yes ./configure --build=x86_64-linux-musl --disable-install-doc --enable-shared \ - # Compile and install Ruby - && make -j $(nproc) \ - && make install \ - # Install RubyGems and Bundler - && mkdir -p /usr/local/etc \ - && echo -e 'install: --no-document\nupdate: --no-document' >/usr/local/etc/gemrc \ - && gem update --system \ - # Cleanup - && cd /tmp \ - && rm -r /usr/src/ruby \ - && apk --no-cache del .deps \ - && rm -rf /root/.gem diff --git a/basic-runtimes/tomcat/Dockerfile b/basic-runtimes/tomcat/Dockerfile deleted file mode 100644 index 92364ba..0000000 --- a/basic-runtimes/tomcat/Dockerfile +++ /dev/null @@ -1,15 +0,0 @@ -FROM java -LABEL maintainer="Disassembler " - -RUN \ - # Install Tomcat 8 - wget http://mirror.hosting90.cz/apache/tomcat/tomcat-8/v8.0.53/bin/apache-tomcat-8.0.53.tar.gz -O /tmp/apache-tomcat-8.tgz \ - && tar xf /tmp/apache-tomcat-8.tgz -C /srv \ - && mv /srv/apache-tomcat-8.0.53 /srv/tomcat \ - # Make catalina.sh available globally - && ln -s /srv/tomcat/bin/catalina.sh /usr/bin/catalina.sh \ - # Cleanup - && rm -rf /srv/tomcat/webapps/ROOT /srv/tomcat/webapps/docs /srv/tomcat/webapps/examples /srv/tomcat/webapps/host-manager /srv/tomcat/webapps/manager \ - && rm -f /tmp/apache-tomcat-8.tgz - -COPY docker/ / diff --git a/basic-runtimes/tomcat/docker/srv/tomcat/bin/setenv.sh b/basic-runtimes/tomcat/srv/tomcat/bin/setenv.sh similarity index 100% rename from basic-runtimes/tomcat/docker/srv/tomcat/bin/setenv.sh rename to basic-runtimes/tomcat/srv/tomcat/bin/setenv.sh diff --git a/basic-runtimes/tomcat/docker/srv/tomcat/conf/logging.properties b/basic-runtimes/tomcat/srv/tomcat/conf/logging.properties similarity index 100% rename from basic-runtimes/tomcat/docker/srv/tomcat/conf/logging.properties rename to basic-runtimes/tomcat/srv/tomcat/conf/logging.properties diff --git a/basic-runtimes/var/lib/lxc/build/config b/basic-runtimes/var/lib/lxc/build/config index 1b02d9d..6e4b8fe 100644 --- a/basic-runtimes/var/lib/lxc/build/config +++ b/basic-runtimes/var/lib/lxc/build/config @@ -9,7 +9,7 @@ lxc.net.0.ipv4.address = 172.17.0.2/16 lxc.net.0.ipv4.gateway = auto # Volumes -lxc.rootfs.path = /var/lib/lxc/build/rootfs +lxc.rootfs.path = /var/lib/lxc/shared/alpine # Mounts lxc.mount.entry = /etc/hosts etc/hosts none bind 0 0 diff --git a/basic.sh b/basic.sh index d6ae22e..0edd746 100755 --- a/basic.sh +++ b/basic.sh @@ -60,10 +60,16 @@ vmmgr create-selfsigned cp ${SOURCE_DIR}/etc/nginx/nginx.conf /etc/nginx/nginx.conf # Configure services -for SERVICE in consolefont crond nginx ntpd lxc sshd swap vmmgr; do +for SERVICE in consolefont crond nginx ntpd lxc swap vmmgr; do rc-update add ${SERVICE} boot service ${SERVICE} start done +# Configure services for DEBUG mode +if [ ${DEBUG:-0} -eq 1 ]; then + rc-update add sshd boot + service sshd start +fi + # Set dummy host and generate related files vmmgr update-host spotter.vm 443