私服仓库 repo.nju.edu.cn Docker Hub Linux 在配置文件 /etc/docker/daemon.json 中加入: { "registry-mirrors": ["https://docker.nju.edu.cn/"] } 重新启动 docker: sudo systemctl restart docker.service 命令行执行 docker info ,如果从输出中看到如下内容,说明配置成功。 Registry Mirrors: https://docker.nju.edu.cn/ macOS 打开 "Docker.app" 进入偏好设置页面(快捷键 ⌘, ) 打开 "Advanced" 选项卡 在 "Registry mirrors" 中添加 https://docker.nju.edu.cn/ 点击下方的 "Restart" 按钮 Docker Desktop 各平台都一样: 打开 Settings-Docker Engine 在 registry-mirrors 中添加 https://docker.nju.edu.cn/ 点击 Apply&Restart GCR Google Container Registry gcr.io 将 gcr.io 替换为 gcr.nju.edu.cn 即可。 如 docker pull gcr.io/cadvisor/cadvisor:v0.39.3 替换为 docker pull gcr.nju.edu.cn/cadvisor/cadvisor:v0.39.3 k8s.gcr.io 将 k8s.gcr.io 替换为 gcr.nju.edu.cn/google-containers 即可。 如 docker pull k8s.gcr.io/kube-proxy:v1.18.6 替换为 docker pull gcr.nju.edu.cn/google-containers/kube-proxy:v1.18.6 GHCR Github Container Registry ghcr.io 将 ghcr.io 替换为 ghcr.nju.edu.cn 即可。 如 docker pull ghcr.io/github/super-linter:latest 替换为 docker pull ghcr.nju.edu.cn/github/super-linter:latest NGC NVIDIA NGC Catalog nvcr.io 将 nvcr.io 替换为 nvcr.nju.edu.cn 或 ngc.nju.edu.cn 即可。 如 docker pull nvcr.io/nvidia/cuda 替换为 docker pull nvcr.nju.edu.cn/nvidia/cuda Quay Quay Container Registry quay.io 将 quay.io 替换为 quay.nju.edu.cn 即可。 如 docker pull quay.io/prometheus/prometheus:latest 替换为 docker pull quay.nju.edu.cn/prometheus/prometheus:latest k8s Kubernetes's container image registry registry.k8s.io 将 registry.k8s.io 替换为 k8s.nju.edu.cn 即可。 如 docker pull registry.k8s.io/busybox 替换为 docker pull k8s.nju.edu.cn/nvidia/cuda Go 南大源采用了阿里云、七牛云和官方源混合的形式。 注意,南大镜像同时提供 go 二进制文件下载,具体文件请 参考链接 。 go 配置方式比较简单,执行以下命令: go env -w GO111MODULE=on # 启用 Go Modules 功能 go env -w GOPROXY="https://repo.nju.edu.cn/repository/go/,direct" # 配置代理 go env | grep GOPROXY # linux 确认配置 go env |findstr "GOPROXY" # windows 确认配置 如有私有模块,可以通过以下命令特殊设置: go env -w GOPRIVATE="*.nju.edu.cn" Maven 南大源采用了阿里云(central + jcenter + gradle-plugin),腾讯云(central+jcenter+google)和 maven central 官方的混合形式。 maven 配置指南 全局配置 配置当前登录用户使用南大源,如果未修改过 maven 的默认配置文件位置,请如下操作: linux 用户在终端中输入以下命令: mkdir ~/.m2 vim ~/.m2/settings.xml windows 用户在 powershell (或者pwsh中) 输入以下命令: mkdir ~/.m2 cd ~/.m2 notepad settings.xml 如果打开的文件为空,粘贴以下内容: nju_mirror * https://repo.nju.edu.cn/repository/maven-public/ 如果已经有内容,则在 mirrors 节点加入子节点 (对于 mirrorOf 值相同的节点,只有首个子节点生效): nju_mirror * https://repo.nju.edu.cn/repository/maven-public/ 保存退出即可使用。 项目配置 如果只在某个项目中使用,则在项目的 pom.xml 中配置: ......[其他配置] nju https://repo.nju.edu.cn/repository/maven-public/ true false maven 私服 南京大学 maven 仓库同时提供 jar 包托管服务 ,本校师生可以将自己编写的 jar 发布到仓库中让其他人使用。此仓库文件 不会同步到其他镜像源 。 从仓库获取文件 将上面提到的仓库地址改为 https://repo.nju.edu.cn/repository/maven-nju/ 即可。 使用此仓库请注意: 此仓库会优先从官方库和其他源中获取包,如果你发布了同名包,会被其他来源的同名包覆盖, 因此请不要也禁止发布同名包或者名称相近包 ; 当仓库网络出现问题或者上游源出现问题时, 可能会导致你下载到仓库其他人发布的同名包 ,这可能不是你想要的,甚至有风险(maven-public 没有此问题); 如果发现和上游仓库 同名包 ,请 填写统计表 ,管理员将会定期删除; 如果发现 恶意同名包或者类似包 ,请 填写统计表 ,管理员将核实后采取措施。 向仓库提交文件 在 ~/.m2/settings.xml 中,为 settings 节点添加以下子节点: nju-server 学工号 统一身份认证密码 在项目的 pom.xml 中,为 project 节点添加以下子节点: nju-server Releases http://repo.nju.edu.cn/repository/maven-releases/ nju-server Snapshot http://repo.nju.edu.cn/repository/maven-snapshots 在项目根目录下运行 mvn deploy 即可发布,若版本号中以 -SNAPSHOT 结尾,会发布到 maven-snapshots, 否则会发布到 maven-releases。 注意 上面配置中的 id 节点值必须相同。 一经发布,仓库 jar 不允许修改和删除 发布过程中你的用户信息会被记录,因此请勿滥用。 请为你的项目使用合适的项目名称、组织名称和版本号,强烈建议不要使用默认的 com.example 。 Gradle 南大源采用了阿里云(central + jcenter + gradle-plugin),腾讯云(central+jcenter+google)和 maven central 官方的混合形式。 gradle 和 maven 使用的是同一个仓库,不过配置方法略有区别。 注意,南大镜像同时提供 gradle 二进制文件下载,将项目文件下的 gradle\wapper\gradle-wrapper.properties 的 distributionUrl 修改为 http://mirror.nju.edu.cn/gradle/gradle-[version].zip 即可,详细版本请 参考链接 。 全局配置 配置当前登录用户使用南大源,如果未修改过 gradle 的默认配置文件位置,请如下操作: linux 用户在终端中输入以下命令: mkdir ~/.gradle vim ~/.gradle/init.gradle windows 用户在 powershell (或者pwsh中) 输入以下命令: mkdir ~/.gradle cd ~/.gradle notepad init.gradle 覆盖写入以下内容: allprojects { buildscript { repositories { def NJU_REPOSITORY_URL = 'https://repo.nju.edu.cn/repository/maven-public/' all { ArtifactRepository repo -> if (repo instanceof MavenArtifactRepository) { def url = repo.url.toString() if (url.startsWith('https://repo1.maven.org/maven2')) { project.logger.lifecycle "Repository ${repo.url} replaced by $NJU_REPOSITORY_URL." remove repo } if (url.startsWith('https://jcenter.bintray.com/')) { project.logger.lifecycle "Repository ${repo.url} deleted." remove repo } if (url.startsWith('https://dl.google.com/dl/android/maven2/')) { project.logger.lifecycle "Repository ${repo.url} deleted." remove repo } if (url.contains('plugins.gradle.org/m2')) { project.logger.lifecycle "Repository ${repo.url} deleted." remove repo } } } maven { url NJU_REPOSITORY_URL } mavenLocal() } } repositories { def NJU_REPOSITORY_URL = 'https://repo.nju.edu.cn/repository/maven-public/' all { ArtifactRepository repo -> if (repo instanceof MavenArtifactRepository) { def url = repo.url.toString() if (url.startsWith('https://repo1.maven.org/maven2')) { project.logger.lifecycle "Repository ${repo.url} replaced by $NJU_REPOSITORY_URL." remove repo } if (url.startsWith('https://jcenter.bintray.com/')) { project.logger.lifecycle "Repository ${repo.url} deleted." remove repo } if (url.startsWith('https://dl.google.com/dl/android/maven2/')) { project.logger.lifecycle "Repository ${repo.url} deleted." remove repo } if (url.contains('plugins.gradle.org/m2')) { project.logger.lifecycle "Repository ${repo.url} deleted." remove repo } } } maven { url NJU_REPOSITORY_URL } mavenLocal() } } 如果已经运行过 gradle ,请先执行一次 gradle --stop 命令关闭所有 gradle 的 daemon, 然后重新运行即可。 项目配置 如果只在某个项目中使用,则在项目的 build.gradle 中配置: buildscript { repositories { maven { url 'https://repo.nju.edu.cn/repository/maven-public/' } } } plugins { ...[你需要用的 gradle 插件] } allprojects { repositories { maven { url 'https://repo.nju.edu.cn/repository/maven-public/' } } } 注意这样可能有时候无法通过镜像下载部分 gradle 插件。 npm Node Package Manager 南大源采用了腾讯云和官方源的混合代理形式。 npm 配置指南 临时使用 npm install [packageName] --registry=https://repo.nju.edu.cn/repository/npm/ 使用此命令可以临时使用南大源下载指定包。 设置为默认源 使用一下命令修改默认源: npm config set registry https://repo.nju.edu.cn/repository/npm/ # 修改源 npm 私服 南京大学 npm 仓库同时提供 npm 包托管服务 ,本校师生可以将自己编写的 js 脚本打包后发布到仓库中让其他人使用。此仓库文件 不会同步到其他镜像源 。 从仓库获取文件 将上面提到的仓库地址改为 https://repo.nju.edu.cn/repository/npm-nju/ 即可。 使用此仓库请注意: 此仓库会优先从官方库和其他源中获取包,如果你发布了同名包,会被其他来源的同名包覆盖, 因此请不要也禁止发布同名包或者名称相近包 ; 当仓库网络出现问题或者上游源出现问题时, 可能会导致你下载到仓库其他人发布的同名包 ,这可能不是你想要的,甚至有风险(pypi 仓库则没有此问题); 如果发现和上游仓库 同名包 ,请 填写统计表 ,管理员将会定期删除; 如果发现 恶意同名包或者类似包 ,请 填写统计表 ,管理员将核实后采取措施。 向仓库提交文件 使用 npm 登陆: npm adduser --registry https://repo.nju.edu.cn/repository/npm-releases/ 其中,邮箱推荐使用南大邮箱,账号密码为统一身份认证账号密码。 在项目的 package.json 中加入以下内容: "publishConfig": { "registry" : "https://repo.nju.edu.cn/repository/npm-releases/" }, 配置 package.json 中的其他配置项。 配置 .npmignore 指定你不想发布的文件(夹)。 构建并推送: npm run build npm publish yarn 配置指南 yarn config set registry https://repo.nju.edu.cn/repository/npm/ # 修改源 yarn 发布的过程和 npm 类似,不过 yarn login 的时候不需要输入密码,在每次发布的时候输入,具体内容请查看 yarn publish 的文档。 PyPI (Python Package Index) Python 包索引(PyPI)是 Python 编程语言的软件存储库。南大源采用了阿里云,腾讯云和官方源的混合代理形式。 pip 配置指南 临时使用 pip install -i https://repo.nju.edu.cn/repository/pypi/simple [packageName] 使用此命令可以临时使用南大源下载指定包。 设置为默认源 如果想将南大源设置为默认源,则可能需要先更新 pip 版本: pip install pip -U # 更新 pip 版本 pip config set global.index-url https://repo.nju.edu.cn/repository/pypi/simple # 修改源 超时说明 由于在第一次用户请求的时候,服务器会从远程(源)服务器获取文件,因此第一次请求部分 大体积包 (如 tensorflow )时,可能会出现以下错误: WARNING: Retrying (Retry(total=4, connect=None, read=None, redirect=None, status=None)) after connection broken by 'ReadTimeoutError("HTTPSConnectionPool(host='repo.nju.edu.cn', port=443): Read timed out. (read timeout=15)")': [uri] WARNING: Retrying (Retry(total=3, connect=None, read=None, redirect=None, status=None)) after connection broken by 'ReadTimeoutError("HTTPSConnectionPool(host='repo.nju.edu.cn', port=443): Read timed out. (read timeout=15)")': [uri] WARNING: Retrying (Retry(total=2, connect=None, read=None, redirect=None, status=None)) after connection broken by 'ReadTimeoutError("HTTPSConnectionPool(host='repo.nju.edu.cn', port=443): Read timed out. (read timeout=15)")': [uri] WARNING: Retrying (Retry(total=1, connect=None, read=None, redirect=None, status=None)) after connection broken by 'ReadTimeoutError("HTTPSConnectionPool(host='repo.nju.edu.cn', port=443): Read timed out. (read timeout=15)")': [uri] WARNING: Retrying (Retry(total=0, connect=None, read=None, redirect=None, status=None)) after connection broken by 'ReadTimeoutError("HTTPSConnectionPool(host='repo.nju.edu.cn', port=443): Read timed out. (read timeout=15)")': [uri] ERROR: Could not install packages due to an OSError: HTTPSConnectionPool(host='repo.nju.edu.cn', port=443): Max retries exceeded with url: [url] (Caused by ReadTimeoutError("HTTPSConnectionPool(host='repo.nju.edu.cn', port=443): Read timed out. (read timeout=15)")) 这是由于初次请求,服务器去其他站下载的原因,稍后一会(一般建议2分钟左右)重新执行该命令即可。 pypi 私服 南京大学 pypi 仓库同时提供 pip 包托管服务 ,本校师生可以将自己编写的 python 脚本打包后发布到仓库中让其他人使用。此仓库文件 不会同步到其他镜像源 。 从仓库获取文件 将上面提到的仓库地址改为 https://repo.nju.edu.cn/repository/pypi-nju/simple 即可。 使用此仓库请注意: 此仓库会优先从官方库和其他源中获取包,如果你发布了同名包,会被其他来源的同名包覆盖, 因此请不要也禁止发布同名包或者名称相近包 ; 当仓库网络出现问题或者上游源出现问题时, 可能会导致你下载到仓库其他人发布的同名包 ,这可能不是你想要的,甚至有风险(pypi 仓库则没有此问题); 如果发现和上游仓库 同名包 ,请 填写统计表 ,管理员将会定期删除; 如果发现 恶意同名包或者类似包 ,请 填写统计表 ,管理员将核实后采取措施。 当由于毕业等原因导致统一身份认证账号过期时,你将不能向该仓库中推送新的包或者已有包的更新,正常情况下你已经提交的包也不会被删除。 向仓库提交文件 linux 用户打开终端并输入以下命令: vim ~/.pypirc windows 用户打开 powershell 或者 pwsh, 输入以下命令: cd ~ notepad .pypirc 在打开的文件中写入以下内容: [distutils] index-servers = nju [nju] repository: https://repo.nju.edu.cn/repository/pypi-releases/ username: [学工号] password: [统一身份认证密码] 在项目根路径执行: python setup.py check python setup.py sdist bdist_wheel upload -r nju 更多关于 python 打包相关的内容,请参考 相关链接 。 注意 一经发布,文件 不允许修改和删除 ; 发布过程中你的用户信息会被记录,因此请勿滥用; 建议为你的包起一个合适的名字和有规则的版本号; 如果想配置多个发布仓库,请 参考链接 。