From dd2fb1eb687605d3ef913edfe766f0b74a8ab4d0 Mon Sep 17 00:00:00 2001 From: Terry Chen Date: Tue, 11 Aug 2015 18:01:41 +0800 Subject: [PATCH] Add Dockerfile and setup.sh --- Dockerfile | 16 ++++++++++++++++ README.md | 10 +++++++++- setup.sh | 20 ++++++++++++++++++++ 3 files changed, 45 insertions(+), 1 deletion(-) create mode 100644 Dockerfile create mode 100755 setup.sh diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..c3b750e --- /dev/null +++ b/Dockerfile @@ -0,0 +1,16 @@ +FROM ubuntu:14.04 +MAINTAINER Terry Chen + +ENV DEBIAN_FRONTEND noninteractive + +RUN \ + apt-get update && \ + apt-get install -y apt-mirror apache2 && \ + apt-get clean && \ + rm -rf /var/lib/apt/lists/* + +VOLUME ["/etc/apt/"] + +EXPOSE 80 +COPY setup.sh /setup.sh +CMD /bin/bash setup.sh diff --git a/README.md b/README.md index 2caa1a9..bcdde03 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,11 @@ # apt-mirror-http-server -Using Docker to construct your Apt mirror HTTP server +Base on Ubuntu, using Docker to construct your Apt mirror HTTP server + +## Usage +``` +docker run -d -P port_number:80 -v /path/your_mirror.list:/etc/apt/ seterrychen/apt-mirror-http-server +``` + +If you don't provide mirror.list file, the program will use default setting. +It will take time to download, then start http server. Using ``docker logs -f container-id`` to check the process. diff --git a/setup.sh b/setup.sh new file mode 100755 index 0000000..22ea20e --- /dev/null +++ b/setup.sh @@ -0,0 +1,20 @@ +#!/bin/bash + +# read mirror.list to link /var/www/package folder +mkdir /var/www/package +for i in `egrep -o 'https?://[^ ]+' /etc/apt/mirror.list`; do + url=${i/http:\/\//''} + target='/var/www/package/' + + IFS='/' read -a distName <<< "$url" + dest=$target${distName[-1]} + if [ ! -h $dest ]; then + echo "create $dest" + ln -s /var/spool/apt-mirror/mirror/$url $dest + fi +done + +sed -i '12s/DocumentRoot \/var\/www\/html/DocumentRoot \/var\/www\/package/' /etc/apache2/sites-enabled/000-default.conf +sed -i '2s/.*/exit 0/' /usr/sbin/policy-rc.d + +apt-mirror && apache2ctl -D FOREGROUND