{"id":13574628,"url":"https://github.com/soulteary/apt-proxy","last_synced_at":"2025-04-04T15:31:35.688Z","repository":{"id":37976649,"uuid":"502291966","full_name":"soulteary/apt-proxy","owner":"soulteary","description":"[Ubuntu / Debian / CentOS / Alpine] Lightweight APT / YUM / APK CHACHE PROXY with only 2MB+ size!","archived":false,"fork":true,"pushed_at":"2024-12-01T10:37:43.000Z","size":539,"stargazers_count":187,"open_issues_count":12,"forks_count":19,"subscribers_count":2,"default_branch":"main","last_synced_at":"2024-12-01T10:39:47.401Z","etag":null,"topics":["alpine","alpine-mirror","apt-cache","apt-cache-ng","apt-cache-proxy","apt-cacher-ng","centos-mirror","debian-mirror","ubuntu-mirror"],"latest_commit_sha":null,"homepage":"https://soulteary.com/2022/11/20/linux-package-download-acceleration-tool-apt-proxy.html","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":"lox/apt-proxy","license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/soulteary.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":"SECURITY.md","support":null}},"created_at":"2022-06-11T08:25:00.000Z","updated_at":"2024-12-01T10:37:47.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/soulteary/apt-proxy","commit_stats":null,"previous_names":[],"tags_count":19,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/soulteary%2Fapt-proxy","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/soulteary%2Fapt-proxy/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/soulteary%2Fapt-proxy/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/soulteary%2Fapt-proxy/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/soulteary","download_url":"https://codeload.github.com/soulteary/apt-proxy/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247202820,"owners_count":20900846,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["alpine","alpine-mirror","apt-cache","apt-cache-ng","apt-cache-proxy","apt-cacher-ng","centos-mirror","debian-mirror","ubuntu-mirror"],"created_at":"2024-08-01T15:00:53.154Z","updated_at":"2025-04-04T15:31:30.680Z","avatar_url":"https://github.com/soulteary.png","language":"Go","funding_links":[],"categories":["Go"],"sub_categories":[],"readme":"# APT Proxy\n\n[![Security Scan](https://github.com/soulteary/apt-proxy/actions/workflows/scan.yml/badge.svg)](https://github.com/soulteary/apt-proxy/actions/workflows/scan.yml) [![Release](https://github.com/soulteary/apt-proxy/actions/workflows/release.yaml/badge.svg)](https://github.com/soulteary/apt-proxy/actions/workflows/release.yaml) [![goreportcard](https://img.shields.io/badge/go%20report-A+-brightgreen.svg?style=flat)](https://goreportcard.com/report/github.com/soulteary/apt-proxy) [![Docker Image](https://img.shields.io/docker/pulls/soulteary/apt-proxy.svg)](https://hub.docker.com/r/soulteary/apt-proxy)\n\n\n\u003cp style=\"text-align: center;\"\u003e\n  \u003ca href=\"README.md\"\u003eENGLISH\u003c/a\u003e | \u003ca href=\"README_CN.md\"  target=\"_blank\"\u003e中文文档\u003c/a\u003e\n\u003c/p\u003e\n\n\u003cimg src=\"example/assets/logo.png\" width=\"64\"/\u003e\n\n\u003e Lightweight **APT CHACHE PROXY** with only 2MB+ size!\n\n\u003cimg src=\"example/assets/preview.png\" width=\"600\"/\u003e\n\nAPT Proxy is a Lightweight and Reliable APT \u0026 YUM \u0026 APK packages (**Ubuntu / Debian / CentOS / ALPINE**) cache tool, supports a large number of common system and Docker usage.\n\nYou can safely use it instead of [apt-cacher-ng](https://www.unix-ag.uni-kl.de/~bloch/acng/).\n\n## Supported Systems and Architectures\n\n- Linux: x86_64 / x86_32\n- ARM: ARM64v8 / ARM32v6 / ARM32v7\n- macOS: x86_64 / M1 ARM64v8\n\n## Usage\n\nJust run it:\n\n```bash\n./apt-proxy\n\n2022/06/12 16:15:40 running apt-proxy\n2022/06/12 16:15:41 Start benchmarking mirrors\n2022/06/12 16:15:41 Finished benchmarking mirrors\n2022/06/12 16:15:41 using fastest mirror https://mirrors.company.ltd/ubuntu/\n2022/06/12 16:15:41 proxy listening on 0.0.0.0:3142\n```\n\nAn APT proxy software with a cache function is started.\n\nThen rewrite the command where you need to execute the `apt-get` command and execute it:\n\n```bash\n# `apt-get update` with apt-proxy service\nhttp_proxy=http://your-domain-or-ip-address:3142 apt-get -o pkgProblemResolver=true -o Acquire::http=true update \n# `apt-get install vim -y` with apt-proxy service\nhttp_proxy=http://your-domain-or-ip-address:3142 apt-get -o pkgProblemResolver=true -o Acquire::http=true install vim -y\n```\n\nWhen we need to execute the above commands repeatedly in batches, the speed of update and installation **will be greatly improved**.\n\n### CentOS 7 / 8\n\nAlthough CentOS uses Yum instead of APT, APT-Proxy also supports its acceleration (CentOS 7):\n\n```bash\ncat /etc/yum.repos.d/CentOS-Base.repo | sed -e s/mirrorlist.*$// | sed -e s/#baseurl/baseurl/ | sed -e s#http://mirror.centos.org#http://your-domain-or-ip-address:3142# | tee /etc/yum.repos.d/CentOS-Base.repo\n```\n\nIn CentOS 8, we need to adjust the software source like this:\n\n```bash\nsed -i -e \"s#mirror.centos.org#http://your-domain-or-ip-address:3142#g\" /etc/yum.repos.d/CentOS-*\nsed -i -e \"s/#baseurl/baseurl/\" /etc/yum.repos.d/CentOS-*\nsed -i -e \"s#\\$releasever/#8-stream/#\" /etc/yum.repos.d/CentOS-*\n```\n\nAfter adjusting the software source, execute `yum update` to verify whether the configuration takes effect.\n\n### Alpine\n\nSimilarly, in addition to providing acceleration for CentOS, it can also provide cache acceleration for Alpine:\n\n```bash\ncat /etc/apk/repositories | sed -e s#https://.*.alpinelinux.org#http://your-domain-or-ip-address:3142# | tee /etc/apk/repositories\n```\n\nAfter adjusting the software source, execute `apk update` to verify whether the configuration takes effect.\n\n### Specified Mirror\n\nThere are currently two ways to specify:\n\n**Use Full URL**\n\n```bash\n# proxy cache for both `ubuntu` and `debian`\n./apt-proxy --ubuntu=https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ --debian=https://mirrors.tuna.tsinghua.edu.cn/debian/\n# proxy cache for `ubuntu` only\n./apt-proxy --mode=ubuntu --ubuntu=https://mirrors.tuna.tsinghua.edu.cn/ubuntu/\n# proxy cache for `debian` only\n./apt-proxy --mode=debian --debian=https://mirrors.tuna.tsinghua.edu.cn/debian/\n```\n\n**Use Shorthand**\n\n```bash\ngo run apt-proxy.go --ubuntu=cn:tsinghua --debian=cn:163\n2022/06/15 10:55:26 running apt-proxy\n2022/06/15 10:55:26 using specify debian mirror https://mirrors.163.com/debian/\n2022/06/15 10:55:26 using specify ubuntu mirror https://mirrors.tuna.tsinghua.edu.cn/ubuntu/\n2022/06/15 10:55:26 proxy listening on 0.0.0.0:3142\n```\n\nShorthand list:\n\n- cn:tsinghua\n- cn:ustc\n- cn:163\n- cn:aliyun\n- cn:huaweicloud\n- cn:tencent\n...\n\n### Speed UP Docker Container\n\nAssuming you have started a container:\n\n```bash\n# Ubuntu\ndocker run --rm -it ubuntu\n# or Debian\ndocker run --rm -it debian\n```\n\nAnd your Apt-Proxy is started on host machine, you can speed up the installation with the following command:\n\n```bash\nhttp_proxy=http://host.docker.internal:3142 apt-get -o Debug::pkgProblemResolver=true -o Debug::Acquire::http=true update \u0026\u0026 \\\nhttp_proxy=http://host.docker.internal:3142 apt-get -o Debug::pkgProblemResolver=true -o Debug::Acquire::http=true install vim -y\n```\n\n## Docker\n\n\u003cimg src=\"example/assets/dockerhub.png\" width=\"600\"/\u003e\n\nJust one command:\n\n```bash\ndocker run -d --name=apt-proxy -p 3142:3142 soulteary/apt-proxy\n```\n\n## Options\n\nView configuration items:\n\n```bash\n./apt-proxy -h\n\nUsage of apt-proxy:\n  -alpine string\n    \tthe alpine mirror for fetching packages\n  -cachedir string\n    \tthe dir to store cache data in (default \"./.aptcache\")\n  -centos string\n    \tthe centos mirror for fetching packages\n  -debian string\n    \tthe debian mirror for fetching packages\n  -debug\n    \twhether to output debugging logging\n  -host string\n    \tthe host to bind to (default \"0.0.0.0\")\n  -mode all\n    \tselect the mode of system to cache: all / `ubuntu` / `debian` / `centos` / `alpine` (default \"all\")\n  -port string\n    \tthe port to bind to (default \"3142\")\n  -ubuntu string\n    \tthe ubuntu mirror for fetching packages\n```\n\n## [WIP] Development\n\nStart the application in development mode:\n\n```bash\ngo run apt-proxy.go\n```\n\n### Run Test And Get Coverage\n\n```bash\n# go test -cover ./...\n?   \tgithub.com/soulteary/apt-proxy\t[no test files]\nok  \tgithub.com/soulteary/apt-proxy/cli\t2.647s\tcoverage: 62.7% of statements\nok  \tgithub.com/soulteary/apt-proxy/internal/benchmark\t5.786s\tcoverage: 91.9% of statements\nok  \tgithub.com/soulteary/apt-proxy/internal/define\t0.258s\tcoverage: 94.1% of statements\nok  \tgithub.com/soulteary/apt-proxy/internal/mirrors\t1.852s\tcoverage: 72.6% of statements\nok  \tgithub.com/soulteary/apt-proxy/internal/rewriter\t6.155s\tcoverage: 69.8% of statements\nok  \tgithub.com/soulteary/apt-proxy/internal/server\t0.649s\tcoverage: 34.1% of statements\nok  \tgithub.com/soulteary/apt-proxy/internal/state\t0.348s\tcoverage: 100.0% of statements\nok  \tgithub.com/soulteary/apt-proxy/pkg/httpcache\t2.162s\tcoverage: 82.5% of statements\n?   \tgithub.com/soulteary/apt-proxy/pkg/httplog\t[no test files]\nok  \tgithub.com/soulteary/apt-proxy/pkg/stream.v1\t0.651s\tcoverage: 100.0% of statements\n?   \tgithub.com/soulteary/apt-proxy/pkg/system\t[no test files]\nok  \tgithub.com/soulteary/apt-proxy/pkg/vfs\t0.374s\tcoverage: 58.9% of statements\n```\n\nView coverage report:\n\n```\ngo test -coverprofile=coverage.out ./...\ngo tool cover -html=coverage.out\n\n# go test -coverprofile=coverage.out ./...\nPASS\ncoverage: 86.7% of statements\nok  \tgithub.com/soulteary/apt-proxy\t0.485s\n\n# go tool cover -html=coverage.out\n```\n\n### Ubuntu / Debian Debugging\n\n```\nhttp_proxy=http://192.168.33.1:3142 apt-get -o Debug::pkgProblemResolver=true -o Debug::Acquire::http=true update\nhttp_proxy=http://192.168.33.1:3142 apt-get -o Debug::pkgProblemResolver=true -o Debug::Acquire::http=true install apache2\n```\n\n## Licenses, contains dependent software\n\nThis project is under the [Apache License 2.0](https://github.com/soulteary/apt-proxy/blob/master/LICENSE), and base on those software (or codebase).\n\n- License NOT Found\n    - [lox/apt-proxy](https://github.com/lox/apt-proxy#readme)\n- MIT License\n    - [lox/httpcache](https://github.com/lox/httpcache/blob/master/LICENSE)\n    - [djherbis/stream](https://github.com/djherbis/stream/blob/master/LICENSE)\n- Mozilla Public License 2.0\n    - [rainycape/vfs](https://github.com/rainycape/vfs/blob/master/LICENSE)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsoulteary%2Fapt-proxy","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsoulteary%2Fapt-proxy","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsoulteary%2Fapt-proxy/lists"}