瀏覽代碼

Merge pull request #2388 from amorZhu/master

Improve user experience in China
Shao Yu-Lung (Allen) 5 年之前
父節點
當前提交
91041e9c56
共有 4 個文件被更改,包括 99 次插入0 次删除
  1. 3 0
      docker-compose.yml
  2. 3 0
      env-example
  3. 10 0
      workspace/Dockerfile
  4. 83 0
      workspace/sources.sh

+ 3 - 0
docker-compose.yml

@@ -77,6 +77,7 @@ services:
           - INSTALL_GEARMAN=${WORKSPACE_INSTALL_GEARMAN}
           - INSTALL_PHPREDIS=${WORKSPACE_INSTALL_PHPREDIS}
           - INSTALL_MSSQL=${WORKSPACE_INSTALL_MSSQL}
+          - NVM_NODEJS_ORG_MIRROR=${WORKSPACE_NVM_NODEJS_ORG_MIRROR}
           - INSTALL_NODE=${WORKSPACE_INSTALL_NODE}
           - NPM_REGISTRY=${WORKSPACE_NPM_REGISTRY}
           - INSTALL_YARN=${WORKSPACE_INSTALL_YARN}
@@ -132,6 +133,8 @@ services:
           - http_proxy
           - https_proxy
           - no_proxy
+          - CHANGE_SOURCE=${CHANGE_SOURCE}
+          - UBUNTU_SOURCE=${UBUNTU_SOURCE}
       volumes:
         - ${APP_CODE_PATH_HOST}:${APP_CODE_PATH_CONTAINER}${APP_CODE_CONTAINER_FLAG}
         - ./php-worker/supervisord.d:/etc/supervisord.d

+ 3 - 0
env-example

@@ -70,6 +70,8 @@ COMPOSE_CONVERT_WINDOWS_PATHS=1
 
 # If you need to change the sources (i.e. to China), set CHANGE_SOURCE to true
 CHANGE_SOURCE=false
+# Set CHANGE_SOURCE and UBUNTU_SOURCE option if you want to change the Ubuntu system sources.list file.
+UBUNTU_SOURCE=aliyun
 
 ### Docker Sync ###########################################
 
@@ -85,6 +87,7 @@ DOCKER_SYNC_STRATEGY=native_osx
 WORKSPACE_COMPOSER_GLOBAL_INSTALL=true
 WORKSPACE_COMPOSER_AUTH=false
 WORKSPACE_COMPOSER_REPO_PACKAGIST=
+WORKSPACE_NVM_NODEJS_ORG_MIRROR=
 WORKSPACE_INSTALL_NODE=true
 WORKSPACE_NODE_VERSION=node
 WORKSPACE_NPM_REGISTRY=

+ 10 - 0
workspace/Dockerfile

@@ -36,6 +36,15 @@ ENV PUID ${PUID}
 ARG PGID=1000
 ENV PGID ${PGID}
 
+ARG CHANGE_SOURCE=false
+ARG UBUNTU_SOURCE
+COPY ./sources.sh /tmp/sources.sh
+
+RUN if [ ${CHANGE_SOURCE} = true ]; then \
+    /bin/sh -c /tmp/sources.sh && \
+    rm -rf /tmp/sources.sh \
+;fi
+
 # always run apt update when start and after add new source list, then clean up at end.
 RUN set -xe; \
     apt-get update -yqq && \
@@ -580,6 +589,7 @@ ARG INSTALL_NPM_ANGULAR_CLI=false
 ARG NPM_REGISTRY
 ENV NPM_REGISTRY ${NPM_REGISTRY}
 ENV NVM_DIR /home/laradock/.nvm
+ENV NVM_NODEJS_ORG_MIRROR=${NVM_NODEJS_ORG_MIRROR}
 
 RUN if [ ${INSTALL_NODE} = true ]; then \
     # Install nvm (A Node Version Manager)

+ 83 - 0
workspace/sources.sh

@@ -0,0 +1,83 @@
+#!/bin/bash
+
+set -xe;
+
+if type "tee" 2>/dev/null && [ -n "${UBUNTU_SOURCE}" ]; then
+    SOURCE_PATH="/etc/apt/sources.list"
+    cp ${SOURCE_PATH} ${SOURCE_PATH}.bak && rm -rf ${SOURCE_PATH}
+    case "${UBUNTU_SOURCE}" in
+        "aliyun")
+            tee ${SOURCE_PATH} <<-'EOF'
+deb http://mirrors.aliyun.com/ubuntu/ bionic main restricted universe multiverse
+deb http://mirrors.aliyun.com/ubuntu/ bionic-security main restricted universe multiverse
+deb http://mirrors.aliyun.com/ubuntu/ bionic-updates main restricted universe multiverse
+deb http://mirrors.aliyun.com/ubuntu/ bionic-proposed main restricted universe multiverse
+deb http://mirrors.aliyun.com/ubuntu/ bionic-backports main restricted universe multiverse
+deb-src http://mirrors.aliyun.com/ubuntu/ bionic main restricted universe multiverse
+deb-src http://mirrors.aliyun.com/ubuntu/ bionic-security main restricted universe multiverse
+deb-src http://mirrors.aliyun.com/ubuntu/ bionic-updates main restricted universe multiverse
+deb-src http://mirrors.aliyun.com/ubuntu/ bionic-proposed main restricted universe multiverse
+deb-src http://mirrors.aliyun.com/ubuntu/ bionic-backports main restricted universe multiverse
+EOF
+;;
+        "zju")
+            tee ${SOURCE_PATH} <<-'EOF'
+deb http://mirrors.zju.edu.cn/ubuntu/ bionic main multiverse restricted universe
+deb http://mirrors.zju.edu.cn/ubuntu/ bionic-backports main multiverse restricted universe
+deb http://mirrors.zju.edu.cn/ubuntu/ bionic-proposed main multiverse restricted universe
+deb http://mirrors.zju.edu.cn/ubuntu/ bionic-security main multiverse restricted universe
+deb http://mirrors.zju.edu.cn/ubuntu/ bionic-updates main multiverse restricted universe
+deb-src http://mirrors.zju.edu.cn/ubuntu/ bionic main multiverse restricted universe
+deb-src http://mirrors.zju.edu.cn/ubuntu/ bionic-backports main multiverse restricted universe
+deb-src http://mirrors.zju.edu.cn/ubuntu/ bionic-proposed main multiverse restricted universe
+deb-src http://mirrors.zju.edu.cn/ubuntu/ bionic-security main multiverse restricted universe
+deb-src http://mirrors.zju.edu.cn/ubuntu/ bionic-updates main multiverse restricted universe
+EOF
+;;
+        "tsinghua")
+            tee ${SOURCE_PATH} <<-'EOF'
+deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic main restricted universe multiverse
+deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic main restricted universe multiverse
+deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-updates main restricted universe multiverse
+deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-updates main restricted universe multiverse
+deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-backports main restricted universe multiverse
+deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-backports main restricted universe multiverse
+deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-security main restricted universe multiverse
+deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-security main restricted universe multiverse
+deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-proposed main restricted universe multiverse
+deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-proposed main restricted universe multiverse
+EOF
+;;
+        "163")
+            tee ${SOURCE_PATH} <<-'EOF'
+deb http://mirrors.163.com/ubuntu/ bionic main restricted universe multiverse
+deb http://mirrors.163.com/ubuntu/ bionic-security main restricted universe multiverse
+deb http://mirrors.163.com/ubuntu/ bionic-updates main restricted universe multiverse
+deb http://mirrors.163.com/ubuntu/ bionic-proposed main restricted universe multiverse
+deb http://mirrors.163.com/ubuntu/ bionic-backports main restricted universe multiverse
+deb-src http://mirrors.163.com/ubuntu/ bionic main restricted universe multiverse
+deb-src http://mirrors.163.com/ubuntu/ bionic-security main restricted universe multiverse
+deb-src http://mirrors.163.com/ubuntu/ bionic-updates main restricted universe multiverse
+deb-src http://mirrors.163.com/ubuntu/ bionic-proposed main restricted universe multiverse
+deb-src http://mirrors.163.com/ubuntu/ bionic-backports main restricted universe multiverse
+EOF
+;;
+        "ustc")
+            tee ${SOURCE_PATH} <<-'EOF'
+deb https://mirrors.ustc.edu.cn/ubuntu/ bionic main restricted universe multiverse
+deb-src https://mirrors.ustc.edu.cn/ubuntu/ bionic main restricted universe multiverse
+deb https://mirrors.ustc.edu.cn/ubuntu/ bionic-updates main restricted universe multiverse
+deb-src https://mirrors.ustc.edu.cn/ubuntu/ bionic-updates main restricted universe multiverse
+deb https://mirrors.ustc.edu.cn/ubuntu/ bionic-backports main restricted universe multiverse
+deb-src https://mirrors.ustc.edu.cn/ubuntu/ bionic-backports main restricted universe multiverse
+deb https://mirrors.ustc.edu.cn/ubuntu/ bionic-security main restricted universe multiverse
+deb-src https://mirrors.ustc.edu.cn/ubuntu/ bionic-security main restricted universe multiverse
+deb https://mirrors.ustc.edu.cn/ubuntu/ bionic-proposed main restricted universe multiverse
+deb-src https://mirrors.ustc.edu.cn/ubuntu/ bionic-proposed main restricted universe multiverse
+EOF
+;;
+        *)
+            echo "Please check whether there is aliyun|zju|tsinghua|163|ustc in the parameter"
+            exit 1;;
+    esac
+fi