From 7bcead756182411ea1f5021bc35cdb2b1ac3c906 Mon Sep 17 00:00:00 2001 From: Megvii Engine Team Date: Wed, 10 Jun 2020 18:36:42 +0800 Subject: [PATCH] ci(docker): add build-arg option to setup yum and pip mirrors GitOrigin-RevId: bb7aa875dad45d98a02d675ffe5610848baa4c92 --- ci/docker_env/manylinux2010/Dockerfile | 4 ++ .../manylinux2010/brainpp_build_image.sh | 9 +++ ci/docker_env/manylinux2010/init_image.sh | 3 + ci/docker_env/manylinux2010/setup_mirror.sh | 65 +++++++++++++++++++ 4 files changed, 81 insertions(+) create mode 100755 ci/docker_env/manylinux2010/brainpp_build_image.sh create mode 100755 ci/docker_env/manylinux2010/setup_mirror.sh diff --git a/ci/docker_env/manylinux2010/Dockerfile b/ci/docker_env/manylinux2010/Dockerfile index 6f563617b..0a434fdb6 100644 --- a/ci/docker_env/manylinux2010/Dockerfile +++ b/ci/docker_env/manylinux2010/Dockerfile @@ -6,6 +6,10 @@ ENV UID=1024 \ LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:/usr/local/cuda/lib64:/usr/local/cuda/lib64/stubs:/opt/cudnn/lib64:/opt/tensorrt/lib \ CPATH=${CPATH}:/usr/local/cuda/include:/opt/cudnn/include:/opt/tensorrt/include +ARG platform +COPY setup_mirror.sh . +RUN ./setup_mirror.sh "$platform" + ADD init_image.sh /tmp RUN /tmp/init_image.sh && rm -f /tmp/init_image.sh diff --git a/ci/docker_env/manylinux2010/brainpp_build_image.sh b/ci/docker_env/manylinux2010/brainpp_build_image.sh new file mode 100755 index 000000000..7ce059a4e --- /dev/null +++ b/ci/docker_env/manylinux2010/brainpp_build_image.sh @@ -0,0 +1,9 @@ +#!/bin/bash + +cd $(dirname $0) + +docker build -t env_manylinux2010:latest . \ + --build-arg platform="brainpp" \ + --build-arg http_proxy="http://proxy.i.brainpp.cn:3128" \ + --build-arg https_proxy="http://proxy.i.brainpp.cn:3128" \ + --build-arg no_proxy="brainpp.cn,.brainpp.ml,.megvii-inc.com,.megvii-op.org,127.0.0.1,localhost" diff --git a/ci/docker_env/manylinux2010/init_image.sh b/ci/docker_env/manylinux2010/init_image.sh index 750498a74..0d44f5f88 100755 --- a/ci/docker_env/manylinux2010/init_image.sh +++ b/ci/docker_env/manylinux2010/init_image.sh @@ -21,6 +21,7 @@ do done pushd /home >/dev/null + echo "Install swig" curl -sSL ${SWIG_URL} | tar xz pushd swig-3.0.12 >/dev/null mkdir build @@ -32,6 +33,7 @@ pushd /home >/dev/null popd >/dev/null rm -rf swig-3.0.12 + echo "Install llvm" curl -sSL ${LLVM_URL} | tar xz pushd llvm-release_60 >/dev/null mkdir build @@ -44,6 +46,7 @@ pushd /home >/dev/null popd >/dev/null rm -rf llvm-release_60 + echo "Install clang" curl -sSL ${CLANG_URL} | tar xz pushd clang-release_60 >/dev/null mkdir build diff --git a/ci/docker_env/manylinux2010/setup_mirror.sh b/ci/docker_env/manylinux2010/setup_mirror.sh new file mode 100755 index 000000000..f3c9f832d --- /dev/null +++ b/ci/docker_env/manylinux2010/setup_mirror.sh @@ -0,0 +1,65 @@ +#!/bin/bash + +set -e + +function set_tuna_yum_mirror() { + cp /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.bak + local repo=/etc/yum.repos.d/CentOS-Base.repo + local plugin=/etc/yum/pluginconf.d/fastestmirror.conf + sed -i "s/mirrorlist=/#mirrorlist=/g" $repo + sed -i "s/#baseurl/baseurl/g" $repo + sed -i "s/mirror.centos.org/mirrors.tuna.tsinghua.edu.cn/g" $repo + sed -i "s/http/https/g" $repo + sed -i "s/enabled=1/enabled=0/g" $plugin + yum clean all + # Build on brainpp unable to pull epel reo metadata so disable this + # https://unix.stackexchange.com/questions/148144/unable-to-pull-epel-repository-metadata + yum --disablerepo="epel" update nss + yum makecache +} + +function set_epel() { + mv /etc/yum.repos.d/epel.repo /etc/yum.repos.d/epel.repo.backup + mv /etc/yum.repos.d/epel-testing.repo /etc/yum.repos.d/epel-testing.repo.backup + curl -o /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-6.repo +} + +function set_yum_mirror() { + mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup + curl -o /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-6.repo + yum makecache +} + +function set_pip_mirror() { +cat > /etc/pip.conf <