From f54ab85aedae671499bafaf72e8b12b26f907d94 Mon Sep 17 00:00:00 2001 From: hyung-hwan Date: Tue, 16 Aug 2022 08:34:37 +0000 Subject: [PATCH] converted Dockerfile.ubtn2004 to multi-stage build --- codepot/docker/Dockerfile.ubnt2004 | 59 +++++++++++++++++++++++++++--- codepot/docker/build-ubnt2004.sh | 36 ------------------ 2 files changed, 54 insertions(+), 41 deletions(-) delete mode 100755 codepot/docker/build-ubnt2004.sh diff --git a/codepot/docker/Dockerfile.ubnt2004 b/codepot/docker/Dockerfile.ubnt2004 index 28a001f4..4fec3e77 100644 --- a/codepot/docker/Dockerfile.ubnt2004 +++ b/codepot/docker/Dockerfile.ubnt2004 @@ -1,5 +1,48 @@ +ARG VROOT=/tmp/codepot-root + +### ------------------------------------------------------------------------------- + +FROM ubuntu:20.04 as installer + +ARG VROOT + +RUN apt update && \ + DEBIAN_FRONTEND=noninteractive apt install -y --no-install-recommends \ + php-dev libsvn-dev make + +COPY codepot-0.4.0.tar.gz /tmp + +RUN \ + cd /tmp && \ + tar -zxvf codepot-0.4.0.tar.gz && \ + cd codepot-0.4.0 && \ + ./configure \ + --prefix=/usr \ + --libdir=/usr/lib64 \ + --sysconfdir=/etc \ + --with-wwwdir=/var/www/html \ + --with-cfgdir=/etc/codepot \ + --with-depotdir=/var/lib/codepot \ + --with-logdir=/var/log/codepot \ + --with-cachedir=/var/cache/codepot \ + --with-phpextdir=`php-config --extension-dir` \ + --with-phpextinidir=`php-config --ini-dir | sed 's|/cli/|/apache2/|g'` && \ + make && make install DESTDIR=${VROOT} && rm -rf ${VROOT}/var/lib/codepot/* + +RUN \ + sed -ri -e 's|^database_hostname[[:space:]]*=[[:space:]]*"localhost"$|database_hostname = "/var/lib/codepot/codepot.db"|g' \ + -e 's|^database_driver[[:space:]]*=[[:space:]]*""$|database_driver = "sqlite"|g' \ + -e 's|^database_use_pdo[[:space:]]*=[[:space:]]*"no"$|database_use_pdo = "yes"|g' ${VROOT}/etc/codepot/codepot.ini + +RUN tar -C ${VROOT} -zcvf /tmp/codepot-root.tar.gz . + + +### ------------------------------------------------------------------------------- + FROM ubuntu:20.04 +ARG VROOT + RUN apt update && \ DEBIAN_FRONTEND=noninteractive apt install -y --no-install-recommends \ subversion apache2 \ @@ -7,12 +50,18 @@ RUN apt update && \ libapache2-mod-perl2 libapache2-mod-svn \ libswitch-perl libconfig-simple-perl libdigest-sha-perl \ libdbd-sqlite3-perl libnet-ldap-perl libsvn-perl libmail-sendmail-perl \ - sqlite3 php-dev libsvn-dev make vim - -COPY build-ubnt2004.sh /tmp -COPY codepot-0.4.0.tar.gz /tmp -RUN /tmp/build-ubnt2004.sh && rm -rf /tmp/* + sqlite3 vim +COPY --from=installer /tmp/codepot-root.tar.gz /tmp COPY apache2-fg.sh /usr/sbin/ +RUN \ + rm -rf /var/www/html && \ + tar -C / -zxvf /tmp/codepot-root.tar.gz && \ + a2enmod rewrite && a2enmod headers && \ + cp -pf /etc/codepot/codepot.httpd /etc/apache2/conf-enabled/codepot.conf && \ + echo "PerlSwitches -Mlib=/etc/codepot/perl" >> /etc/apache2/conf-enabled/perl.conf && \ + sed -ri -e 's|^max_execution_time[[:space:]]*=.*$|max_execution_time = 120|g' /etc/php/*/apache2/php.ini && \ + rm -rf /tmp/* + ENTRYPOINT ["/usr/sbin/apache2-fg.sh"] diff --git a/codepot/docker/build-ubnt2004.sh b/codepot/docker/build-ubnt2004.sh deleted file mode 100755 index a730b31c..00000000 --- a/codepot/docker/build-ubnt2004.sh +++ /dev/null @@ -1,36 +0,0 @@ -cd /tmp - -## delete all files under /var/www/html -rm -rf /var/www/html/* - -a2enmod rewrite -a2enmod headers - -tar -zxvf codepot-0.4.0.tar.gz && mv -f codepot-0.4.0 codepot && \ -cd codepot && \ -./configure \ - --prefix=/usr \ - --libdir=/usr/lib64 \ - --sysconfdir=/etc \ - --with-wwwdir=/var/www/html \ - --with-cfgdir=/etc/codepot \ - --with-depotdir=/var/lib/codepot \ - --with-logdir=/var/log/codepot \ - --with-cachedir=/var/cache/codepot \ - --with-phpextdir=`php-config --extension-dir` \ - --with-phpextinidir=`php-config --ini-dir | sed 's|/cli/|/apache2/|g'` && \ -make && make install && \ -cd ../.. && \ -rm -rf /var/lib/codepot/* && \ -sed -ri -e 's|^database_hostname[[:space:]]*=[[:space:]]*"localhost"$|database_hostname = "/var/lib/codepot/codepot.db"|g' \ - -e 's|^database_driver[[:space:]]*=[[:space:]]*""$|database_driver = "sqlite"|g' \ - -e 's|^database_use_pdo[[:space:]]*=[[:space:]]*"no"$|database_use_pdo = "yes"|g' /etc/codepot/codepot.ini && \ -cp -pf /etc/codepot/codepot.httpd /etc/apache2/conf-enabled/codepot.conf && \ -echo "PerlSwitches -Mlib=/etc/codepot/perl" >> /etc/apache2/conf-enabled/perl.conf && \ -sed -ri -e 's|^max_execution_time[[:space:]]*=.*$|max_execution_time = 120|g' /etc/php/*/apache2/php.ini - - -apt remove --purge -y --allow-remove-essential php-dev libsvn-dev make libfdisk1 && \ -apt autoremove --purge -y && rm -rf /var/lib/apt/lists/* - -rm -rf /root/.subversion