Compare commits
33 Commits
Author | SHA1 | Date | |
---|---|---|---|
b4c6017871 | |||
6f8da3c8e4 | |||
caece7197d | |||
c549c75107 | |||
bc3736a5a4 | |||
6f8096650c | |||
2e84d93951 | |||
be0d3cb859 | |||
d402abd69b | |||
a2b750a71e | |||
3b4e6fdc38 | |||
587425b1ed | |||
0d8f43c685 | |||
1256279e1c | |||
9217e7367e | |||
0b821850d2 | |||
a18f1b41fa | |||
5fbe1f088a | |||
ca7375fab1 | |||
d261e0763b | |||
d90e22b44f | |||
4ff75ed861 | |||
3e27d9bf26 | |||
866b8f4dfd | |||
7083e9c0f1 | |||
9cbf6878fd | |||
79cef474fd | |||
96f723f82b | |||
4729a2490e | |||
edc907b857 | |||
645a3f9121 | |||
d857782830 | |||
abac966eca |
18
.drone.yml
Normal file
18
.drone.yml
Normal 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
|
28
Dockerfile
28
Dockerfile
@ -2,6 +2,33 @@ 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,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
|
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
|
||||||
@ -24,4 +51,5 @@ 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
|
||||||
|
@ -1,36 +1,70 @@
|
|||||||
# sneak/ubuntumirror
|
# sneak/ubuntumirror
|
||||||
|
|
||||||
Docker container for syncing bionic ubuntu LTS mirrors
|
Docker image for syncing ubuntu LTS mirrors to reduce network traffic and
|
||||||
to reduce network traffic and speed up build times.
|
speed up build times.
|
||||||
|
|
||||||
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
|
# Levers
|
||||||
|
|
||||||
* `MIRROR_ARCHITECTURES`
|
## Paths
|
||||||
* default `amd64`.
|
|
||||||
|
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`.
|
* You may want `i386,amd64`.
|
||||||
* `MIRROR_CATEGORIES`
|
* `UBUNTU_MIRROR_CATEGORIES`
|
||||||
* default `main,universe`.
|
* Default `main,universe,restricted,multiverse`. Will use lots of disk.
|
||||||
* You may want `main,universe,restricted,multiverse`. Will use lots of
|
* You may want `main,universe`.
|
||||||
disk.
|
|
||||||
* `UBUNTU_MIRROR_PROJECTS`
|
* `UBUNTU_MIRROR_PROJECTS`
|
||||||
* default `xenial,xenial-updates,xenial-security,xenial-backports,bionic,bionic-updates,bionic-security,bionic-backports`.
|
* Default
|
||||||
* `UBUNTU_MIRROR_SOURCE`
|
`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`.
|
* 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).
|
||||||
* `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)
|
* default `43200` (12h)
|
||||||
* You may want `10800` (3h)
|
* You may want `10800` (3h)
|
||||||
|
|
||||||
# Example dnsmasq setup
|
# Example Startup
|
||||||
|
|
||||||
```
|
```
|
||||||
apt update && apt -y install dnsmasq
|
docker rm -f local-ubuntu-mirror
|
||||||
echo address=/mirrors.ubuntu.com/172.17.0.1 > /etc/dnsmasq.d/ubuntu-mirror-local
|
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
|
# Example CapRover Definition File
|
||||||
and bounce the docker daemon. Future containers will talk to your local
|
|
||||||
mirror.
|
```
|
||||||
|
{
|
||||||
|
"schemaVersion": 2,
|
||||||
|
"imageName": "sneak/ubuntumirror@sha256:7de7cc8245106bb574029a2dedca5aa218af08d802b989cdc7857fb57f876a02"
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
# Author
|
||||||
|
|
||||||
|
sneak <[sneak@sneak.berlin](mailto:sneak@sneak.berlin)>
|
||||||
|
|
||||||
|
# License
|
||||||
|
|
||||||
|
This software is released into the public domain.
|
||||||
|
|
||||||
|
@ -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
|
|
@ -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 true ; do
|
while sleep 1 ; do
|
||||||
cd /opt/mirror && make
|
cd /opt/mirror && make
|
||||||
|
|
||||||
sleep ${MIRROR_INTERVAL_SECONDS:-43200}
|
sleep ${MIRROR_UPDATE_INTERVAL_SECONDS}
|
||||||
done
|
done
|
||||||
|
46
mirror/syncubuntu.sh
Executable file → Normal file
46
mirror/syncubuntu.sh
Executable file → Normal file
@ -4,24 +4,42 @@ set -x
|
|||||||
THISDIR="$(cd $(dirname "$BASH_SOURCE") && pwd -P)"
|
THISDIR="$(cd $(dirname "$BASH_SOURCE") && pwd -P)"
|
||||||
DST="/var/mirror"
|
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
|
chmod a+r $DST/mirrors.txt
|
||||||
|
|
||||||
mkdir -p "$DST/ubuntu"
|
mkdir -p "$DST/ubuntu"
|
||||||
|
|
||||||
export GNUPGHOME="/etc/debmirror/ubuntu"
|
export GNUPGHOME="/etc/debmirror/ubuntu"
|
||||||
|
|
||||||
debmirror \
|
SOURCEOPT="--nosource"
|
||||||
-a ${MIRROR_ARCHITECTURES:-amd64} \
|
if [[ "$UBUNTU_ENABLE_SOURCE_MIRRORING" != "false" ]]; then
|
||||||
--no-source \
|
SOURCEOPT="--source"
|
||||||
-s ${MIRROR_CATEGORIES:-main,universe} \
|
fi
|
||||||
-h ${UBUNTU_MIRROR_SOURCE:-archive.ubuntu.com} \
|
|
||||||
-d ${UBUNTU_MIRROR_PROJECTS:-bionic,bionic-updates,bionic-security,bionic-backports} \
|
|
||||||
--ignore-small-errors \
|
|
||||||
-r /ubuntu \
|
|
||||||
--getcontents \
|
|
||||||
--progress \
|
|
||||||
--method=http \
|
|
||||||
$DST/ubuntu
|
|
||||||
|
|
||||||
chmod -R a+rX $DST
|
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_MIRROR_UPSTREAM_PATH" \
|
||||||
|
--getcontents \
|
||||||
|
--progress \
|
||||||
|
--method=http \
|
||||||
|
$DST/ubuntu
|
||||||
|
if [[ $? -eq 0 ]]; then
|
||||||
|
DONE=1
|
||||||
|
fi
|
||||||
|
chmod -R a+rX $DST
|
||||||
|
sleep 1
|
||||||
|
done
|
||||||
|
@ -3,11 +3,14 @@ worker_processes auto;
|
|||||||
|
|
||||||
pid /var/run/nginx.pid;
|
pid /var/run/nginx.pid;
|
||||||
|
|
||||||
|
error_log /dev/stdout info;
|
||||||
|
|
||||||
events {
|
events {
|
||||||
worker_connections 1024;
|
worker_connections 1024;
|
||||||
}
|
}
|
||||||
|
|
||||||
http {
|
http {
|
||||||
|
access_log /dev/stdout;
|
||||||
include /etc/nginx/mime.types;
|
include /etc/nginx/mime.types;
|
||||||
default_type application/octet-stream;
|
default_type application/octet-stream;
|
||||||
|
|
||||||
@ -30,12 +33,12 @@ http {
|
|||||||
|
|
||||||
index index.html index.htm;
|
index index.html index.htm;
|
||||||
|
|
||||||
#location /ubuntu/ {
|
location /ubuntu/ {
|
||||||
# # alias, not root!
|
# # alias, not root!
|
||||||
# # trailing slash important!
|
# # trailing slash important!
|
||||||
# alias /var/mirror/ubuntu/;
|
# alias /var/mirror/ubuntu/;
|
||||||
# autoindex on;
|
autoindex on;
|
||||||
#}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
11
sources.list
11
sources.list
@ -1,7 +1,4 @@
|
|||||||
# this can't be {us.,}archive.ubuntu.org because on the box
|
deb mirror://mirrors.ubuntu.com/mirrors.txt bionic main universe restricted multiverse
|
||||||
# with dnsmasq changing that host to itself, rebuilding this fails
|
deb mirror://mirrors.ubuntu.com/mirrors.txt bionic-updates main universe restricted multiverse
|
||||||
# unless the container is running already
|
deb mirror://mirrors.ubuntu.com/mirrors.txt bionic-security main universe restricted multiverse
|
||||||
deb http://mirrors.sonic.net/ubuntu bionic main universe
|
deb mirror://mirrors.ubuntu.com/mirrors.txt bionic-backports main universe restricted multiverse
|
||||||
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
|
|
||||||
|
@ -1,15 +0,0 @@
|
|||||||
#!/bin/bash
|
|
||||||
|
|
||||||
docker rm -f local-ubuntu-mirror
|
|
||||||
docker run -d --name local-ubuntu-mirror \
|
|
||||||
-v /storage/mirrors/ubuntu/ubuntu:/var/mirror/ubuntu \
|
|
||||||
--env UBUNTU_MIRROR_SOURCE=us.archive.ubuntu.com \
|
|
||||||
--env MIRROR_INTERVAL_SECONDS=10800 \
|
|
||||||
--env MIRROR_CATEGORIES=main,universe,restricted,multiverse \
|
|
||||||
--env MIRROR_ARCHITECTURES=amd64 \
|
|
||||||
--env UBUNTU_MIRROR_PROJECTS=bionic,bionic-updates,bionic-security,bionic-backports \
|
|
||||||
--dns 8.8.8.8 \
|
|
||||||
--dns 8.8.4.4 \
|
|
||||||
-p 172.17.0.1:80:80 \
|
|
||||||
--restart unless-stopped \
|
|
||||||
sneak/ubuntumirror:latest
|
|
Loading…
Reference in New Issue
Block a user