A contrib/repo-cache.nginx.conf => contrib/repo-cache.nginx.conf +61 -0
@@ 0,0 1,61 @@
+upstream alpine-mirrors {
+ least_conn;
+
+ server unix:/run/nginx/alpine-dl-cdn.sock;
+ server unix:/run/nginx/alpine-dl-2.sock backup;
+
+ keepalive 10;
+}
+
+server {
+ listen unix:/run/nginx/alpine-dl-cdn.sock;
+
+ location / {
+ proxy_pass http://dl-cdn.alpinelinux.org/alpine/;
+ }
+}
+
+server {
+ listen unix:/run/nginx/alpine-dl-2.sock;
+
+ location / {
+ proxy_pass http://dl-2.alpinelinux.org/alpine/;
+ }
+}
+
+proxy_cache_path /var/lib/nginx/proxy-cache/repo-cache
+ levels=2
+ keys_zone=repo-cache:10M
+ inactive=1y
+ max_size=64G
+ use_temp_path=off;
+
+server {
+ listen 80;
+ server_name repo-cache.local;
+
+ proxy_cache_revalidate on;
+ proxy_http_version 1.1;
+ proxy_set_header Connection "";
+ proxy_cache repo-cache;
+ proxy_cache_valid any 1m;
+ proxy_cache_valid 200 1d;
+ add_header X-Served-By $host always;
+ add_header X-Cache $upstream_cache_status always;
+
+ proxy_cache_use_stale error timeout invalid_header http_500 http_502
+ http_503 http_404;
+
+ location / {
+ return 404;
+ }
+
+ location /alpine/ {
+ proxy_pass http://alpine-mirrors/;
+ }
+
+ location ~ ^/alpine/(?<target_uri>.*/APKINDEX\.tar\.gz)$ {
+ proxy_pass http://alpine-mirrors/$target_uri;
+ proxy_cache_valid 200 1m;
+ }
+}
M images/alpine/genimg => images/alpine/genimg +10 -5
@@ 45,7 45,7 @@ mount /dev/nbd0p1 /mnt/boot
swapon /dev/nbd0p2
# TODO: Remove bash
-apk add -U -X http://dl-cdn.alpinelinux.org/alpine/$release/main/ \
+apk add -U -X http://repo-cache.local/alpine/$release/main/ \
--allow-untrusted \
--arch="$arch" \
--root=/mnt \
@@ 83,14 83,19 @@ run_root setup-timezone -z UTC
if [ "$release" = "edge" ]
then
cat >/mnt/etc/apk/repositories <<EOF
-http://dl-cdn.alpinelinux.org/alpine/$release/main
-http://dl-cdn.alpinelinux.org/alpine/$release/community
-http://dl-cdn.alpinelinux.org/alpine/$release/testing
+http://repo-cache.local/alpine/$release/main
+http://repo-cache.local/alpine/$release/community
+http://repo-cache.local/alpine/$release/testing
EOF
else
- run_root setup-apkrepos -f
+ cat >/mnt/etc/apk/repositories <<EOF
+http://repo-cache.local/alpine/$release/main
+http://repo-cache.local/alpine/$release/community
+EOF
fi
+echo '172.17.0.1 repo-cache.local' >> /mnt/etc/hosts
+
extlinux -i /mnt/boot
run_root rc-update add ntpd default