From 967dffa798ee0e3866e953f598ec2710235c626c Mon Sep 17 00:00:00 2001 From: Jeffrey Paul Date: Fri, 8 Apr 2016 22:41:48 +0200 Subject: [PATCH] initial --- Dockerfile | 21 +++++++++++++++++++++ mirror.run | 4 ++++ mirror/Makefile | 6 ++++++ mirror/syncubuntu.sh | 19 +++++++++++++++++++ nginx.conf | 41 +++++++++++++++++++++++++++++++++++++++++ nginx.run | 3 +++ 6 files changed, 94 insertions(+) create mode 100644 Dockerfile create mode 100644 mirror.run create mode 100644 mirror/Makefile create mode 100755 mirror/syncubuntu.sh create mode 100644 nginx.conf create mode 100644 nginx.run diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..0139d10 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,21 @@ +FROM phusion/baseimage:0.9.17 + +VOLUME /var/mirror + +RUN echo "#!/bin/sh\nexit 101" > /usr/sbin/policy-rc.d +RUN apt-get update +RUN apt-get install -y run-one nginx make debmirror + +ADD ./mirror /opt/mirror +ADD ./mirror.run /etc/service/mirror/run +ADD nginx.conf /etc/nginx/nginx.conf +ADD ./nginx.run /etc/service/nginx/run + +RUN chmod +x /etc/service/nginx/run && \ + chmod +x /etc/service/mirror/run + +RUN \ + gpg --import /usr/share/keyrings/ubuntu-archive-keyring.gpg && \ + gpg --import /usr/share/keyrings/ubuntu-master-keyring.gpg + +EXPOSE 80 diff --git a/mirror.run b/mirror.run new file mode 100644 index 0000000..8fe80e7 --- /dev/null +++ b/mirror.run @@ -0,0 +1,4 @@ +#!/bin/bash + +cd /opt/mirror && make +sleep 21600 diff --git a/mirror/Makefile b/mirror/Makefile new file mode 100644 index 0000000..afec957 --- /dev/null +++ b/mirror/Makefile @@ -0,0 +1,6 @@ +.PHONY: mirror + +default: mirror + +mirror: + run-one-until-success bash mirror.sh diff --git a/mirror/syncubuntu.sh b/mirror/syncubuntu.sh new file mode 100755 index 0000000..5cefbc0 --- /dev/null +++ b/mirror/syncubuntu.sh @@ -0,0 +1,19 @@ +#!/bin/bash +set -x + +THISDIR="$(cd $(dirname "$BASH_SOURCE") && pwd -P)" +DST="/var/mirror" + +debmirror \ + -a i386,amd64 \ + --no-source \ + -s main,restricted,universe,multiverse \ + -h ${UBUNTU_MIRROR_SOURCE:-archive.ubuntu.com} + -d trusty,trusty-updates,trusty-security,trusty-backports \ + -d xenial,xenial-updates,xenial-security,xenial-backports \ + -r /ubuntu \ + --progress \ + --method=http \ + $DST/ubuntu + +chmod -R a+rX $DST/ubuntu diff --git a/nginx.conf b/nginx.conf new file mode 100644 index 0000000..480cf3b --- /dev/null +++ b/nginx.conf @@ -0,0 +1,41 @@ +user daemon; +worker_processes auto; + +pid /var/run/nginx.pid; + +events { + worker_connections 1024; +} + +http { + include /etc/nginx/mime.types; + default_type application/octet-stream; + + sendfile on; + keepalive_timeout 10; + gzip off; + + # default, no host name + server { + + listen 80 default_server; + charset utf-8; + + server_name _; + + root /var/empty; + + index index.html index.htm; + + location / { + deny all; + } + + location /ubuntu/ { + root /var/mirror/ubuntu; + autoindex on; + } + + } +} + diff --git a/nginx.run b/nginx.run new file mode 100644 index 0000000..bbb4eea --- /dev/null +++ b/nginx.run @@ -0,0 +1,3 @@ +#!/bin/bash + +exec nginx -g "daemon off;"