Add Dockerfile and setup.sh

This commit is contained in:
Terry Chen 2015-08-11 18:01:41 +08:00
parent 67a2b6e8d3
commit dd2fb1eb68
3 changed files with 45 additions and 1 deletions

16
Dockerfile Normal file
View File

@ -0,0 +1,16 @@
FROM ubuntu:14.04
MAINTAINER Terry Chen <seterrychen@gmail.com>
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

View File

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

20
setup.sh Executable file
View File

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