Compare commits

..

41 Commits

Author SHA1 Message Date
b4c6017871 enable autoindexing for ubuntu mirror
Some checks failed
continuous-integration/drone/push Build is passing
continuous-integration/drone/pr Build is failing
2020-03-01 12:00:58 +00:00
6f8da3c8e4 Update 'mirror/syncubuntu.sh'
Some checks failed
continuous-integration/drone/pr Build is failing
continuous-integration/drone/push Build is passing
2020-03-01 08:59:57 +00:00
caece7197d Update 'Dockerfile'
All checks were successful
continuous-integration/drone/push Build is passing
2020-03-01 08:59:35 +00:00
c549c75107 add main/debian-installer to categories
All checks were successful
continuous-integration/drone/push Build is passing
2020-02-16 08:23:00 -08:00
bc3736a5a4 try to correct di-dist arg
All checks were successful
continuous-integration/drone/push Build is passing
2020-02-16 08:11:34 -08:00
6f8096650c Merge branch 'next'
All checks were successful
continuous-integration/drone/push Build is passing
2020-02-16 08:05:36 -08:00
2e84d93951 sync installer stuff
All checks were successful
continuous-integration/drone/push Build is passing
2020-02-16 08:01:45 -08:00
be0d3cb859 Merge branch 'next' of sneak/docker-ubuntumirror into master
All checks were successful
continuous-integration/drone/push Build is passing
2020-02-16 14:12:50 +00:00
d402abd69b make nginx log to stdout
Some checks reported errors
continuous-integration/drone/push Build is passing
continuous-integration/drone/pr Build was killed
2020-02-16 06:05:16 -08:00
a2b750a71e fix indentation in example
All checks were successful
continuous-integration/drone/push Build is passing
2020-02-15 12:45:46 -08:00
3b4e6fdc38 revert .drone.yml
All checks were successful
continuous-integration/drone/push Build is passing
2020-02-15 12:16:12 -08:00
587425b1ed kickoff CI 2020-02-15 12:14:58 -08:00
0d8f43c685 fix bug 2020-02-15 11:41:56 -08:00
1256279e1c update .drone.yml to push latest 2020-02-15 11:08:40 -08:00
9217e7367e update drone.yml 2020-02-15 11:02:56 -08:00
0b821850d2 push master as latest as well
All checks were successful
continuous-integration/drone/push Build is passing
2020-02-15 10:59:00 -08:00
a18f1b41fa update readme 2020-02-15 10:57:52 -08:00
5fbe1f088a Merge branch 'sneak/prepfocal' of git.eeqj.de:sneak/docker-ubuntumirror into sneak/prepfocal
All checks were successful
continuous-integration/drone/push Build is passing
2020-02-15 10:37:32 -08:00
ca7375fab1 update sources.list 2020-02-15 10:37:17 -08:00
d261e0763b Update '.drone.yml'
Some checks reported errors
continuous-integration/drone/push Build was killed
2020-02-15 18:33:53 +00:00
d90e22b44f update readme, fix some bugs
All checks were successful
continuous-integration/drone/push Build is passing
2020-02-15 10:29:22 -08:00
4ff75ed861 update readme, fix bugs
Some checks failed
continuous-integration/drone/push Build is failing
2020-02-15 10:21:00 -08:00
3e27d9bf26 move startup script
Some checks failed
continuous-integration/drone/push Build is failing
2020-02-15 10:14:26 -08:00
866b8f4dfd update exmaple startup file 2020-02-15 10:14:11 -08:00
7083e9c0f1 update for focal, also to support source mirror 2020-02-15 09:55:25 -08:00
9cbf6878fd Update 'Dockerfile'
Some checks failed
continuous-integration/drone/push Build is failing
2020-02-15 17:45:58 +00:00
79cef474fd Update 'Dockerfile'
Some checks failed
continuous-integration/drone/push Build is failing
2020-02-15 17:44:46 +00:00
96f723f82b Update 'Dockerfile'
All checks were successful
continuous-integration/drone/push Build is passing
2020-02-15 17:44:17 +00:00
4729a2490e Update '.drone.yml'
All checks were successful
continuous-integration/drone/push Build is passing
2020-02-15 17:39:38 +00:00
edc907b857 make mirror directory a docker volume
Some checks failed
continuous-integration/drone/push Build is failing
2020-02-08 05:30:08 -08:00
645a3f9121 prepping for release in caprover
Some checks failed
continuous-integration/drone/push Build is failing
2020-02-08 05:29:08 -08:00
d857782830 Update '.drone.yml'
Some checks failed
continuous-integration/drone/push Build is failing
2020-02-08 05:13:06 +00:00
abac966eca Add '.drone.yml' 2020-02-08 05:01:23 +00:00
f03fecaa5e
add local mirror startup script 2019-03-20 17:39:38 -07:00
18828fdc8e updates 2019-01-25 06:10:37 +00:00
d607b6ddc4 add --getcontents debmirror for apt-file 2019-01-25 05:58:11 +00:00
449d0f31a2 Merge branch 'master' of github.com:sneak/docker-ubuntumirror 2019-01-25 03:12:31 +00:00
38a1da6c68
update xenial->bionic, add restricted and multiverse 2019-01-25 11:50:51 +09:00
d84229454c
update for bionic 2018-10-01 15:02:57 -07:00
b1e8729290 updated to xenial for fixed debmirror for translations
see https://bugs.launchpad.net/ubuntu/+source/debmirror/+bug/1565585
2016-09-12 11:14:06 +02:00
79a90753c7 now supports specifying projects via env vars 2016-09-01 03:38:03 +02:00
8 changed files with 145 additions and 69 deletions

18
.drone.yml Normal file
View File

@ -0,0 +1,18 @@
kind: pipeline
name: default
steps:
- name: docker
image: plugins/docker
network_mode: bridge
settings:
repo: sneak/ubuntumirror
username:
from_secret: docker_username
password:
from_secret: docker_password
tags:
- ${DRONE_BRANCH//\//-}-${DRONE_COMMIT_SHA:0:8}
- ${DRONE_COMMIT_SHA}
- ${DRONE_BRANCH/\//-}
- latest

View File

@ -1,13 +1,40 @@
FROM phusion/baseimage:0.9.18
FROM phusion/baseimage:0.11
VOLUME /var/mirror
ENV MIRROR_UPDATE_INTERVAL_SECONDS 43200
ENV UBUNTU_MIRROR_ARCHITECTURES amd64
# set to anything but 'false' to mirror source code as well
ENV UBUNTU_ENABLE_SOURCE_MIRRORING false
ENV UBUNTU_MIRROR_CATEGORIES main,universe,restricted,multiverse,main/debian-installer
ENV UBUNTU_MIRROR_UPSTREAM archive.ubuntu.com
ENV UBUNTU_MIRROR_UPSTREAM_PATH /ubuntu
ENV UBUNTU_MIRROR_PROJECTS bionic,bionic-updates,bionic-security,bionic-backports,focal,focal-updates,focal-security,focal-backports
# The following is the URL populated in /mirrors.txt as used by mirror://
# protocol scheme in sources.list
# the idea is that you can DNS rewrite 'mirrors.ubuntu.com' to this mirror
# and it will return a "list" of mirrors that includes only itself.
# then you can safely use something like the following in your sources.list
# and it will work with max speed on your own dns-rewritten lan and in the
# unmodified datacenter talking to the real mirrors.ubuntu.com:
#
# MURM="main universe restricted multiverse"
# C="$(lsb_release -cs)"
# M="mirror://mirrors.ubuntu.com/mirrors.txt"
# echo "deb $M $C $MURM" > /etc/apt/sources.list.new
# echo "deb $M $C-updates $MURM" >> /etc/apt/sources.list.new
# echo "deb $M $C-backports $MURM" >> /etc/apt/sources.list.new
# echo "deb $M $C-security $MURM" >> /etc/apt/sources.list.new
# mv /etc/apt/sources.list.new /etc/apt/sources.list
ENV THIS_MIRROR_URL http://172.17.0.1/ubuntu/
ADD ./sources.list /etc/apt/sources.list
RUN echo "#!/bin/sh\nexit 101" > /usr/sbin/policy-rc.d
# phusion baseimage says i'm not supposed to do this
# and i don't care:
RUN apt-get update && apt-get upgrade -y
RUN apt-get install -y run-one nginx make debmirror
RUN apt-get install -y run-one nginx make debmirror xz-utils
ADD ./mirror /opt/mirror
ADD ./mirror.run /etc/service/mirror/run
@ -22,6 +49,7 @@ RUN \
mkdir -p $GNUPGHOME && \
chmod go-rwx $GNUPGHOME && \
gpg --import /usr/share/keyrings/ubuntu-archive-keyring.gpg && \
cp $GNUPGHOME/pubring.gpg $GNUPGHOME/trustedkeys.gpg
cp $GNUPGHOME/pubring.kbx $GNUPGHOME/trustedkeys.kbx
EXPOSE 80

View File

@ -1,45 +1,70 @@
# sneak/ubuntumirror
Docker container for syncing trusty and xenial ubuntu LTS mirrors
to reduce network traffic and speed up build times.
Docker image for syncing ubuntu LTS mirrors to reduce network traffic and
speed up build times.
I recommend deploying this with a `--dns 172.17.0.1` in your
`/etc/default/docker` and dnsmasq bound to 172.17.0.1:53 to rewrite
`archive.ubuntu.com` to `172.17.0.1` (which this image will be listening and
serving on).
Then even your builds (where you can't specify links) will go fast.
Then even your builds (where you can't specify links to other containers by
hostname) will go fast.
# Levers
* `MIRROR_ARCHITECTURES`
## Paths
The mirror stores all the data in a docker volume at path
`/var/mirror/ubuntu`. Map that somewhere else if you like.
## Environment Variables
* `UBUNTU_MIRROR_ARCHITECTURES`
* default `amd64`.
* You may want `i386,amd64`.
* `MIRROR_CATEGORIES`
* default `main,universe`.
* You may want `main,universe,restricted,multiverse`. Will use lots of
disk.
* `UBUNTU_MIRROR_SOURCE`
* `UBUNTU_MIRROR_CATEGORIES`
* Default `main,universe,restricted,multiverse`. Will use lots of disk.
* You may want `main,universe`.
* `UBUNTU_MIRROR_PROJECTS`
* Default
`bionic,bionic-updates,bionic-security,bionic-backports,focal,focal-updates,focal-security,focal-backports`.
* You may want only `focal,focal-updates,focal-security,focal-backports`.
* `UBUNTU_MIRROR_UPSTREAM` - upstream server to mirror from
* default `archive.ubuntu.com`.
* You may want `xx.archive.ubuntu.com` (where `xx` is your country
code).
* `MIRROR_INTERVAL_SECONDS` - mirror sync interval
* `UBUNTU_ENABLE_SOURCE_MIRRORING` - do we want to mirror all the source code too?
* Default ``
* You may want `1` if you want to use up even more disk for your mirror
* `MIRROR_UPDATE_INTERVAL_SECONDS` - mirror update interval
* default `43200` (12h)
* You may want `10800` (3h)
# Example dnsmasq setup
# Example Startup
```
apt-get update && apt-get -y install dnsmasq
cat > /etc/dnsmasq.d/docker <<EOF
no-resolv
server=8.8.8.8
server=8.8.4.4
EOF
echo "172.17.0.1 archive.ubuntu.com" >> /etc/hosts
service dnsmasq restart
docker rm -f local-ubuntu-mirror
docker run -d --name local-ubuntu-mirror \
-v /storage/mirrors/ubuntu:/var/mirror/ubuntu \
--env MIRROR_UPDATE_INTERVAL_SECONDS=3600 \
--env UBUNTU_MIRROR_ARCHITECTURES=amd64 \
--env UBUNTU_MIRROR_UPSTREAM=us.archive.ubuntu.com \
--env UBUNTU_MIRROR_PROJECTS=focal,focal-updates,focal-security,focal-backports \
-p 8080:80 \
--restart unless-stopped \
sneak/ubuntumirror@sha256:7de7cc8245106bb574029a2dedca5aa218af08d802b989cdc7857fb57f876a02
```
Then, just add `--dns 172.17.0.1` to your /etc/default/docker opts
and bounce the docker daemon. Future containers will talk to your local
mirror.
# Example CapRover Definition File
```
{
"schemaVersion": 2,
"imageName": "sneak/ubuntumirror@sha256:7de7cc8245106bb574029a2dedca5aa218af08d802b989cdc7857fb57f876a02"
}
```
# Author
sneak &lt;[sneak@sneak.berlin](mailto:sneak@sneak.berlin)&gt;
# License
This software is released into the public domain.

View File

@ -1,15 +0,0 @@
version: '2.0'
services:
mirror:
hostname: mirror
image: sneak/ubuntumirror
build: .
network_mode: bridge
volumes:
- "/mnt/scratch/mirror:/var/mirror"
ports:
- "172.17.0.1:80:80"
environment:
- UBUNTU_MIRROR_SOURCE=de.archive.ubuntu.com
- MIRROR_CATEGORIES=main,universe,restricted

View File

@ -6,8 +6,8 @@ export HOME=/root
# cleanup previous runs
rm -rf /var/mirror/ubuntu/.temp
while true ; do
while sleep 1 ; do
cd /opt/mirror && make
sleep ${MIRROR_INTERVAL_SECONDS:-43200}
sleep ${MIRROR_UPDATE_INTERVAL_SECONDS}
done

41
mirror/syncubuntu.sh Executable file → Normal file
View File

@ -4,25 +4,42 @@ set -x
THISDIR="$(cd $(dirname "$BASH_SOURCE") && pwd -P)"
DST="/var/mirror"
echo "http://172.17.0.1/ubuntu/" > $DST/mirrors.txt
echo "$THIS_MIRROR_URL" > $DST/mirrors.txt
chmod a+r $DST/mirrors.txt
mkdir -p "$DST/ubuntu"
export GNUPGHOME="/etc/debmirror/ubuntu"
debmirror \
-a ${MIRROR_ARCHITECTURES:-amd64} \
--no-source \
-s ${MIRROR_CATEGORIES:-main,universe} \
-h ${UBUNTU_MIRROR_SOURCE:-archive.ubuntu.com} \
-d trusty,trusty-updates,trusty-security,trusty-backports \
-d xenial,xenial-updates,xenial-security,xenial-backports \
SOURCEOPT="--nosource"
if [[ "$UBUNTU_ENABLE_SOURCE_MIRRORING" != "false" ]]; then
SOURCEOPT="--source"
fi
DONE=0
DIDIST="$(
echo -n "$UBUNTU_MIRROR_PROJECTS" | tr "," "\n" | grep -v "\-" | tr "\n" ","
)"
while [[ $DONE -eq 0 ]]; do
debmirror \
-a ${UBUNTU_MIRROR_ARCHITECTURES} \
-s ${UBUNTU_MIRROR_CATEGORIES} \
-h ${UBUNTU_MIRROR_UPSTREAM} \
-d ${UBUNTU_MIRROR_PROJECTS} \
$SOURCEOPT \
--di-dist="$DIDIST" \
--di-arch=arches \
--ignore-small-errors \
-r /ubuntu \
-r "$UBUNTU_MIRROR_UPSTREAM_PATH" \
--getcontents \
--progress \
--method=http \
$DST/ubuntu
chmod -R a+rX $DST
if [[ $? -eq 0 ]]; then
DONE=1
fi
chmod -R a+rX $DST
sleep 1
done

View File

@ -3,11 +3,14 @@ worker_processes auto;
pid /var/run/nginx.pid;
error_log /dev/stdout info;
events {
worker_connections 1024;
}
http {
access_log /dev/stdout;
include /etc/nginx/mime.types;
default_type application/octet-stream;
@ -30,12 +33,12 @@ http {
index index.html index.htm;
#location /ubuntu/ {
location /ubuntu/ {
# # alias, not root!
# # trailing slash important!
# alias /var/mirror/ubuntu/;
# autoindex on;
#}
autoindex on;
}
}
}

View File

@ -1,4 +1,4 @@
deb mirror://mirrors.ubuntu.com/mirrors.txt trusty main universe
deb mirror://mirrors.ubuntu.com/mirrors.txt trusty-updates main universe
deb mirror://mirrors.ubuntu.com/mirrors.txt trusty-backports main universe
deb mirror://mirrors.ubuntu.com/mirrors.txt trusty-security main universe
deb mirror://mirrors.ubuntu.com/mirrors.txt bionic main universe restricted multiverse
deb mirror://mirrors.ubuntu.com/mirrors.txt bionic-updates main universe restricted multiverse
deb mirror://mirrors.ubuntu.com/mirrors.txt bionic-security main universe restricted multiverse
deb mirror://mirrors.ubuntu.com/mirrors.txt bionic-backports main universe restricted multiverse