diff --git a/README.md b/README.md index 2f94306..3b1195f 100644 --- a/README.md +++ b/README.md @@ -17,17 +17,32 @@ pip config set global.index-url https://mirrors.martin98.com/repository/pypi-gro npm config set registry https://mirrors.martin98.com/repository/npm-group/ ``` -##### docker 容器中 +#### dockerfile +##### DEB822 格式 ```bash RUN --mount=type=cache,target=/var/cache/apt \ --mount=type=cache,target=/var/lib/apt \ - sed -i '6,$d' /etc/apt/sources.list.d/dhttps://mirrors.mebian.sources && \ - sed -i 's|http://deb.debian.org/debian|artin98.com/repository/debian-tsinghua/|g' /etc/apt/sources.list.d/debian.sources && \ - apt update && \ - apt install -y --no-install-recommends \ - gcc \ - g++ \ - python3-dev + APT_OPTIONS="-o Acquire::https::mirrors.martin98.com::Verify-Peer=false -o Acquire::https::mirrors.martin98.com::Verify-Host=false" \ + type=$(cat /etc/*release | grep ^ID= | cut -d= -f2) && \ + sed -i '6,$d' /etc/apt/sources.list.d/${type}.sources && \ + sed -i "s|http://deb.debian.org/debian|https://mirrors.martin98.com/repository/${type}-tsinghua/|g" /etc/apt/sources.list.d/${type}.sources && \ + apt update $APT_OPTIONS && apt install $APT_OPTIONS -y ca-certificates curl && update-ca-certificates +``` +##### 传统格式 +```bash +RUN --mount=type=cache,target=/var/cache/apt \ + --mount=type=cache,target=/var/lib/apt \ + APT_OPTIONS="-o Acquire::https::mirrors.martin98.com::Verify-Peer=false -o Acquire::https::mirrors.martin98.com::Verify-Host=false" \ + type=$(cat /etc/*release | grep ^ID= | cut -d= -f2) && \ + release=$(cat /etc/*release | grep VERSION_CODENAME | cut -d= -f2) && \ + components=$([ "${type}" = "debian" ] && echo "main contrib non-free non-free-firmware" || ([ "${type}" = "ubuntu" ] && echo "main restricted universe multiverse")) && \ + + echo "deb https://mirrors.martin98.com/repository/${type}-tsinghua-${release}${suite#noble}/ ${suite} ${components}" + + echo "deb https://mirrors.martin98.com/repository/${type}-tsinghua-${release}/ ${suite} ${components}" + sed -i '6,$d' /etc/apt/sources.list.d/${type}.sources && \ + sed -i "s|http://deb.debian.org/debian|https://mirrors.martin98.com/repository/${type}-tsinghua/|g" /etc/apt/sources.list.d/${type}.sources && \ + apt update $APT_OPTIONS && apt install $APT_OPTIONS -y ca-certificates && update-ca-certificates ``` #### 进入容器 diff --git a/init-apt.sh b/init-apt.sh index 01144a8..b26b472 100644 --- a/init-apt.sh +++ b/init-apt.sh @@ -1,22 +1,30 @@ #!/bin/bash -# 配置 ubuntu 源 -if [ -f /etc/apt/sources.list.d/ubuntu.sources ]; then - cat > /etc/apt/sources.list.d/ubuntu.sources < /etc/apt/sources.list.d/${type}.sources < /etc/apt/sources.list.d/debian.sources < /etc/apt/sources.list <