Compare commits

..

No commits in common. "5fbe1f088a31a9792b1ede6274dcab6b07cb1b40" and "18828fdc8ee58a3fad78271ab688e7b62061e451" have entirely different histories.

7 changed files with 48 additions and 105 deletions

View File

@ -1,18 +0,0 @@
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_COMMIT_SHA}
- ${DRONE_BRANCH/\//-}

View File

@ -2,32 +2,6 @@ FROM phusion/baseimage:0.11
VOLUME /var/mirror 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
ENV UBUNTU_MIRROR_UPSTREAM archive.ubuntu.com
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 ADD ./sources.list /etc/apt/sources.list
RUN echo "#!/bin/sh\nexit 101" > /usr/sbin/policy-rc.d RUN echo "#!/bin/sh\nexit 101" > /usr/sbin/policy-rc.d
# phusion baseimage says i'm not supposed to do this # phusion baseimage says i'm not supposed to do this
@ -50,5 +24,4 @@ RUN \
gpg --import /usr/share/keyrings/ubuntu-archive-keyring.gpg && \ gpg --import /usr/share/keyrings/ubuntu-archive-keyring.gpg && \
cp $GNUPGHOME/pubring.kbx $GNUPGHOME/trustedkeys.kbx cp $GNUPGHOME/pubring.kbx $GNUPGHOME/trustedkeys.kbx
EXPOSE 80 EXPOSE 80

View File

@ -1,61 +1,36 @@
# sneak/ubuntumirror # sneak/ubuntumirror
Docker image for syncing ubuntu LTS mirrors to reduce network traffic and Docker container for syncing bionic ubuntu LTS mirrors
speed up build times. to reduce network traffic and speed up build times.
Then even your builds (where you can't specify links to other containers by Then even your builds (where you can't specify links) will go fast.
hostname) will go fast.
# Levers # Levers
## Paths * `MIRROR_ARCHITECTURES`
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`. * default `amd64`.
* You may want `i386,amd64`. * You may want `i386,amd64`.
* `UBUNTU_MIRROR_CATEGORIES` * `MIRROR_CATEGORIES`
* Default `main,universe,restricted,multiverse`. Will use lots of disk. * default `main,universe`.
* You may want `main,universe`. * You may want `main,universe,restricted,multiverse`. Will use lots of
disk.
* `UBUNTU_MIRROR_PROJECTS` * `UBUNTU_MIRROR_PROJECTS`
* Default * default `xenial,xenial-updates,xenial-security,xenial-backports,bionic,bionic-updates,bionic-security,bionic-backports`.
`bionic,bionic-updates,bionic-security,bionic-backports,focal,focal-updates,focal-security,focal-backports`. * `UBUNTU_MIRROR_SOURCE`
* You may want only `focal,focal-updates,focal-security,focal-backports`.
* `UBUNTU_MIRROR_UPSTREAM` - upstream server to mirror from
* default `archive.ubuntu.com`. * default `archive.ubuntu.com`.
* You may want `xx.archive.ubuntu.com` (where `xx` is your country * You may want `xx.archive.ubuntu.com` (where `xx` is your country
code). code).
* `UBUNTU_ENABLE_SOURCE_MIRRORING` - do we want to mirror all the source code too? * `MIRROR_INTERVAL_SECONDS` - mirror sync interval
* 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) * default `43200` (12h)
* You may want `10800` (3h) * You may want `10800` (3h)
# Example Startup # Example dnsmasq setup
``` ```
docker rm -f local-ubuntu-mirror apt update && apt -y install dnsmasq
docker run -d --name local-ubuntu-mirror \ echo address=/mirrors.ubuntu.com/172.17.0.1 > /etc/dnsmasq.d/ubuntu-mirror-local
-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:latest
``` ```
# Example CapRover Definition File 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.
{
"schemaVersion": 2,
"imageName": "sneak/ubuntumirror:latest"
}
```

15
docker-compose.yml Normal file
View File

@ -0,0 +1,15 @@
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 # cleanup previous runs
rm -rf /var/mirror/ubuntu/.temp rm -rf /var/mirror/ubuntu/.temp
while sleep 1 ; do while true ; do
cd /opt/mirror && make cd /opt/mirror && make
sleep ${MIRROR_INTERVAL_SECONDS} sleep ${MIRROR_INTERVAL_SECONDS:-43200}
done done

View File

@ -4,24 +4,19 @@ set -x
THISDIR="$(cd $(dirname "$BASH_SOURCE") && pwd -P)" THISDIR="$(cd $(dirname "$BASH_SOURCE") && pwd -P)"
DST="/var/mirror" DST="/var/mirror"
echo "$THIS_MIRROR_URL" > $DST/mirrors.txt echo "http://172.17.0.1/ubuntu/" > $DST/mirrors.txt
chmod a+r $DST/mirrors.txt chmod a+r $DST/mirrors.txt
mkdir -p "$DST/ubuntu" mkdir -p "$DST/ubuntu"
export GNUPGHOME="/etc/debmirror/ubuntu" export GNUPGHOME="/etc/debmirror/ubuntu"
SOURCEOPT="--nosource"
if [[ "$UBUNTU_ENABLE_SOURCE_MIRRORING" != "false" ]]; then
SOURCEOPT="--source"
fi
debmirror \ debmirror \
-a ${UBUNTU_MIRROR_ARCHITECTURES} \ -a ${MIRROR_ARCHITECTURES:-amd64} \
-s ${UBUNTU_MIRROR_CATEGORIES} \ --no-source \
-h ${UBUNTU_MIRROR_UPSTREAM} \ -s ${MIRROR_CATEGORIES:-main,universe} \
-d ${UBUNTU_MIRROR_PROJECTS} \ -h ${UBUNTU_MIRROR_SOURCE:-archive.ubuntu.com} \
$SOURCEOPT \ -d ${UBUNTU_MIRROR_PROJECTS:-bionic,bionic-updates,bionic-security,bionic-backports} \
--ignore-small-errors \ --ignore-small-errors \
-r /ubuntu \ -r /ubuntu \
--getcontents \ --getcontents \

View File

@ -1,4 +1,7 @@
deb mirror://mirrors.ubuntu.com/mirrors.txt bionic main universe restricted multiverse # this can't be {us.,}archive.ubuntu.org because on the box
deb mirror://mirrors.ubuntu.com/mirrors.txt bionic-updates main universe restricted multiverse # with dnsmasq changing that host to itself, rebuilding this fails
deb mirror://mirrors.ubuntu.com/mirrors.txt bionic-security main universe restricted multiverse # unless the container is running already
deb mirror://mirrors.ubuntu.com/mirrors.txt bionic-backports main universe restricted multiverse deb http://mirrors.sonic.net/ubuntu bionic main universe
deb http://mirrors.sonic.net/ubuntu bionic-updates main universe
deb http://mirrors.sonic.net/ubuntu bionic-backports main universe
deb http://mirrors.sonic.net/ubuntu bionic-security main universe