Merge branch 'main' of https://git.send.nrw/sendnrw/go-ubuntu-mirror
All checks were successful
release-tag / release-image (push) Successful in 1m37s

This commit is contained in:
2025-10-21 07:19:12 +02:00
2 changed files with 29 additions and 7 deletions

View File

@@ -1,13 +1,12 @@
version: "3.9"
services:
updater:
container_name: ubuntu-mirror-updater
restart: unless-stopped
image: git.send.nrw/sendnrw/ubuntu-mirror-sync:latest
volumes:
- /docker/ubuntu-apt-mirror/data:/var/spool/apt-mirror
networks:
- traefik-net
image: compose-updater
web:
image: git.send.nrw/sendnrw/go-ubuntu-mirror:latest
container_name: ubuntu-mirror-web
@@ -15,20 +14,31 @@ services:
depends_on:
- updater
volumes:
- /docker/ubuntu-apt-mirror/data:/data
command: -archive=/data/mirror/archive.ubuntu.com/ubuntu -security=/data/mirror/security.ubuntu.com/ubuntu -old=/data/mirror/old-releases.ubuntu.com/ubuntu -autoindex=true -cache=600 -addr=:8080 -trust-proxy=true -log-json=false
- /docker/ubuntu-apt-mirror/data:/data:ro
command:
- -archive=/data/mirror/archive.ubuntu.com/ubuntu
- -security=/data/mirror/security.ubuntu.com/ubuntu
- -old=/data/mirror/old-releases.ubuntu.com/ubuntu
- -ms=/data/mirror/packages.microsoft.com/repos
- -autoindex=true
- -cache=600
- -addr=:8080
- -trust-proxy=true
- -log-json=false
labels:
- traefik.enable=true
- traefik.docker.network=traefik-net
- traefik.http.routers.ubuntu_mirror.rule=Host(`ubuntu-24-04.send.nrw`)
- traefik.http.routers.ubuntu_mirror.entrypoints=websecure
- traefik.http.routers.ubuntu_mirror.tls=true
- traefik.http.routers.ubuntu_mirror.tls.certresolver=letsencrypt
- traefik.http.routers.ubuntu_mirror.service=ubuntu_mirror_svc
- traefik.http.services.ubuntu_mirror_svc.loadbalancer.server.port=8080
- traefik.http.services.ubuntu_mirror_svc.loadbalancer.server.scheme=http
- traefik.http.routers.ubuntu_mirror_http.rule=Host(`ubuntu-24-04.send.nrw`)
- traefik.http.routers.ubuntu_mirror_http.entrypoints=web
- traefik.http.routers.ubuntu_mirror_http.service=ubuntu_mirror_svc
- traefik.http.routers.ubuntu_mirror_http.middlewares=to-https@docker
- traefik.http.services.ubuntu_mirror_svc.loadbalancer.server.port=8080
- traefik.http.services.ubuntu_mirror_svc.loadbalancer.server.scheme=http
- traefik.http.middlewares.to-https.redirectscheme.scheme=https
- traefik.http.middlewares.to-https.redirectscheme.permanent=true
networks:

12
main.go
View File

@@ -211,6 +211,7 @@ func main() {
archiveRoot = flag.String("archive", "/data/mirror/archive.ubuntu.com/ubuntu", "archive ubuntu root")
securityRoot = flag.String("security", "/data/mirror/security.ubuntu.com/ubuntu", "security ubuntu root")
oldReleases = flag.String("old", "/data/mirror/old-releases.ubuntu.com/ubuntu", "old-releases ubuntu root")
msRoot = flag.String("ms", "/data/mirror/packages.microsoft.com/repos", "microsoft repos root")
autoIndex = flag.Bool("autoindex", true, "enable directory listings")
cacheSeconds = flag.Int("cache", 600, "Cache-Control max-age seconds (0 to disable)")
trustProxy = flag.Bool("trust-proxy", true, "trust X-Forwarded-For / X-Real-IP")
@@ -247,6 +248,17 @@ func main() {
mux := http.NewServeMux()
mux.Handle("/ubuntu/", http.StripPrefix("/ubuntu", handler))
// Microsoft-Repos unter /ms/ (nur wenn vorhanden)
if st, err := os.Stat(*msRoot); err == nil && st.IsDir() {
mux.Handle("/ms/", http.StripPrefix("/ms", fileHandler{
fs: http.Dir(*msRoot),
autoIndex: *autoIndex,
cacheMaxAge: time.Duration(*cacheSeconds) * time.Second,
}))
log.Printf("serving Microsoft repos at /ms from %s", *msRoot)
} else {
log.Printf("warn: microsoft root not found (%s) — /ms disabled", *msRoot)
}
mux.HandleFunc("/healthz", func(w http.ResponseWriter, r *http.Request) {
w.WriteHeader(http.StatusOK)
_, _ = w.Write([]byte("ok"))