加速Docker镜像编译之更换软件源

原创
2018/05/10 17:46
阅读数 1.7W

一、不同系统更换源

1、Ubuntu

sed -i 's/archive.ubuntu.com/mirrors.aliyun.com/g' /etc/apt/sources.list

请确保具有执行权限

Docker

FROM ubuntu

MAINTAINER dingdayu <614422099@qq.com>

ENV ANDROID_COMPILE_SDK 25
ENV VERSION_SDK_TOOLS 3859397
ENV ANDROID_HOME "/sdk"
ENV PATH "${PATH}:${ANDROID_HOME}/tools:${ANDROID_HOME}/tools/bin:${ANDROID_HOME}/platform-tools"

RUN sed -i 's/http:\/\/archive\.ubuntu\.com\/ubuntu\//http:\/\/mirrors\.aliyun\.com\/ubuntu\//g' /etc/apt/sources.list

RUN apt-get -qqy update && \
	apt-get install -qqy --no-install-recommends \
	curl unzip lib32stdc++6 lib32z1 lib32ncurses5 lib32gcc1 lib32stdc++6 libc6-i386 html2text openjdk-8-jdk \
	&& rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*

# download android-sdk
RUN curl -s -o sdk-tools.zip https://dl.google.com/android/repository/sdk-tools-linux-${VERSION_SDK_TOOLS}.zip && \
	unzip /sdk-tools.zip -d /sdk && rm -v /sdk-tools.zip

RUN mkdir -p $ANDROID_HOME/licenses/ && \
    echo "8933bad161af4178b1185d1a37fbf41ea5269c55\nd56f5187479451eabf01fb78af6dfcb131a6481e" > $ANDROID_HOME/licenses/android-sdk-license && \
    echo "84831b9409646a918e30573bab4c9c91346d8abd" > $ANDROID_HOME/licenses/android-sdk-preview-license

# Upadte sdkmanager
RUN mkdir -p /root/.android && \
  touch /root/.android/repositories.cfg && \
  sdkmanager --update 

一个基于UbuntuAndroid编译环境。

2、Alpine

sed -i 's/dl-cdn.alpinelinux.org/mirrors.ustc.edu.cn/g' /etc/apk/repositories

Docker

FROM composer

LABEL maintainer="dingdayu <614422099@qq.com>" \
	version="v0.3" \
	description="PHP-CI-DOCKER"

# 更新安装源
RUN sed -i 's/dl-cdn.alpinelinux.org/mirrors.ustc.edu.cn/g' /etc/apk/repositories

# 安装基础库
RUN apk add --no-cache libmcrypt-dev freetype libpng libjpeg-turbo freetype-dev libpng-dev libjpeg-turbo-dev $PHPIZE_DEPS

# 安装PHP扩展
RUN docker-php-ext-install pdo_mysql gd opcache pcntl bcmath

# 安装PECL扩展
RUN pecl install xdebug redis \
	&& docker-php-ext-enable xdebug \
	&& docker-php-ext-enable redis

# 移除基础库
RUN apk del --no-cache libmcrypt-dev freetype-dev libpng-dev libjpeg-turbo-dev

# 清理不用缓存
RUN rm -rf /tmp/* /usr/local/lib/php/doc/* /var/cache/apk/*

基于 composer 的 PHP运行环境,composer 基于 php:7-alpine3.7, php:7-alpine3.7 基于 alpine:3.7

composer > > php:7-alpine3.7

3、CentOS

curl -o /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-`lsb_release -r | grep -oP "\d" | head -1`.repo

or

curl -o /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-`lsb_release -r | awk -F '[.:\t]+' '{print $2}'`.repo

请确保已经安装了curl,并备份了CentOS-Base.repo

备份脚本:

mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup

二、国内几个公开源

1、阿里开源镜像服务

  • 域名解析DNS
  • 网络授时NTP
  • Linux镜像加速

提供了:centos, debian, ubuntu, fedora, deepin, kubernetes, raspbian 等加速

https://opsx.alibaba.com/?lang=zh-cn

2、网易开源镜像站

提供了:centos, debian, ubuntu, fedora, deepin, nginx, mysql 等加速

http://mirrors.163.com/

3、清华教育源

高质量镜像源,更新速度快,质量不错。

提供了:centos, debian, ubuntu, fedora, deepin, nginx, mysql 等加速

https://mirrors.tuna.tsinghua.edu.cn

我的博客即将搬运同步至腾讯云+社区,邀请大家一同入驻:https://cloud.tencent.com/developer/support-plan?invite_code=ja747lv0vjmm

展开阅读全文
打赏
0
0 收藏
分享
加载中
更多评论
打赏
0 评论
0 收藏
0
分享
返回顶部
顶部