Skip to content

Commit 91041e9

Browse files
authored
Merge pull request laradock#2388 from amorZhu/master
Improve user experience in China
2 parents 64573a4 + 4978785 commit 91041e9

4 files changed

Lines changed: 99 additions & 0 deletions

File tree

docker-compose.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@ services:
7777
- INSTALL_GEARMAN=${WORKSPACE_INSTALL_GEARMAN}
7878
- INSTALL_PHPREDIS=${WORKSPACE_INSTALL_PHPREDIS}
7979
- INSTALL_MSSQL=${WORKSPACE_INSTALL_MSSQL}
80+
- NVM_NODEJS_ORG_MIRROR=${WORKSPACE_NVM_NODEJS_ORG_MIRROR}
8081
- INSTALL_NODE=${WORKSPACE_INSTALL_NODE}
8182
- NPM_REGISTRY=${WORKSPACE_NPM_REGISTRY}
8283
- INSTALL_YARN=${WORKSPACE_INSTALL_YARN}
@@ -132,6 +133,8 @@ services:
132133
- http_proxy
133134
- https_proxy
134135
- no_proxy
136+
- CHANGE_SOURCE=${CHANGE_SOURCE}
137+
- UBUNTU_SOURCE=${UBUNTU_SOURCE}
135138
volumes:
136139
- ${APP_CODE_PATH_HOST}:${APP_CODE_PATH_CONTAINER}${APP_CODE_CONTAINER_FLAG}
137140
- ./php-worker/supervisord.d:/etc/supervisord.d

env-example

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,8 @@ COMPOSE_CONVERT_WINDOWS_PATHS=1
7070

7171
# If you need to change the sources (i.e. to China), set CHANGE_SOURCE to true
7272
CHANGE_SOURCE=false
73+
# Set CHANGE_SOURCE and UBUNTU_SOURCE option if you want to change the Ubuntu system sources.list file.
74+
UBUNTU_SOURCE=aliyun
7375

7476
### Docker Sync ###########################################
7577

@@ -85,6 +87,7 @@ DOCKER_SYNC_STRATEGY=native_osx
8587
WORKSPACE_COMPOSER_GLOBAL_INSTALL=true
8688
WORKSPACE_COMPOSER_AUTH=false
8789
WORKSPACE_COMPOSER_REPO_PACKAGIST=
90+
WORKSPACE_NVM_NODEJS_ORG_MIRROR=
8891
WORKSPACE_INSTALL_NODE=true
8992
WORKSPACE_NODE_VERSION=node
9093
WORKSPACE_NPM_REGISTRY=

workspace/Dockerfile

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,15 @@ ENV PUID ${PUID}
3636
ARG PGID=1000
3737
ENV PGID ${PGID}
3838

39+
ARG CHANGE_SOURCE=false
40+
ARG UBUNTU_SOURCE
41+
COPY ./sources.sh /tmp/sources.sh
42+
43+
RUN if [ ${CHANGE_SOURCE} = true ]; then \
44+
/bin/sh -c /tmp/sources.sh && \
45+
rm -rf /tmp/sources.sh \
46+
;fi
47+
3948
# always run apt update when start and after add new source list, then clean up at end.
4049
RUN set -xe; \
4150
apt-get update -yqq && \
@@ -580,6 +589,7 @@ ARG INSTALL_NPM_ANGULAR_CLI=false
580589
ARG NPM_REGISTRY
581590
ENV NPM_REGISTRY ${NPM_REGISTRY}
582591
ENV NVM_DIR /home/laradock/.nvm
592+
ENV NVM_NODEJS_ORG_MIRROR=${NVM_NODEJS_ORG_MIRROR}
583593

584594
RUN if [ ${INSTALL_NODE} = true ]; then \
585595
# Install nvm (A Node Version Manager)

workspace/sources.sh

Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
#!/bin/bash
2+
3+
set -xe;
4+
5+
if type "tee" 2>/dev/null && [ -n "${UBUNTU_SOURCE}" ]; then
6+
SOURCE_PATH="/etc/apt/sources.list"
7+
cp ${SOURCE_PATH} ${SOURCE_PATH}.bak && rm -rf ${SOURCE_PATH}
8+
case "${UBUNTU_SOURCE}" in
9+
"aliyun")
10+
tee ${SOURCE_PATH} <<-'EOF'
11+
deb http://mirrors.aliyun.com/ubuntu/ bionic main restricted universe multiverse
12+
deb http://mirrors.aliyun.com/ubuntu/ bionic-security main restricted universe multiverse
13+
deb http://mirrors.aliyun.com/ubuntu/ bionic-updates main restricted universe multiverse
14+
deb http://mirrors.aliyun.com/ubuntu/ bionic-proposed main restricted universe multiverse
15+
deb http://mirrors.aliyun.com/ubuntu/ bionic-backports main restricted universe multiverse
16+
deb-src http://mirrors.aliyun.com/ubuntu/ bionic main restricted universe multiverse
17+
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-security main restricted universe multiverse
18+
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-updates main restricted universe multiverse
19+
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-proposed main restricted universe multiverse
20+
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-backports main restricted universe multiverse
21+
EOF
22+
;;
23+
"zju")
24+
tee ${SOURCE_PATH} <<-'EOF'
25+
deb http://mirrors.zju.edu.cn/ubuntu/ bionic main multiverse restricted universe
26+
deb http://mirrors.zju.edu.cn/ubuntu/ bionic-backports main multiverse restricted universe
27+
deb http://mirrors.zju.edu.cn/ubuntu/ bionic-proposed main multiverse restricted universe
28+
deb http://mirrors.zju.edu.cn/ubuntu/ bionic-security main multiverse restricted universe
29+
deb http://mirrors.zju.edu.cn/ubuntu/ bionic-updates main multiverse restricted universe
30+
deb-src http://mirrors.zju.edu.cn/ubuntu/ bionic main multiverse restricted universe
31+
deb-src http://mirrors.zju.edu.cn/ubuntu/ bionic-backports main multiverse restricted universe
32+
deb-src http://mirrors.zju.edu.cn/ubuntu/ bionic-proposed main multiverse restricted universe
33+
deb-src http://mirrors.zju.edu.cn/ubuntu/ bionic-security main multiverse restricted universe
34+
deb-src http://mirrors.zju.edu.cn/ubuntu/ bionic-updates main multiverse restricted universe
35+
EOF
36+
;;
37+
"tsinghua")
38+
tee ${SOURCE_PATH} <<-'EOF'
39+
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic main restricted universe multiverse
40+
deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic main restricted universe multiverse
41+
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-updates main restricted universe multiverse
42+
deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-updates main restricted universe multiverse
43+
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-backports main restricted universe multiverse
44+
deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-backports main restricted universe multiverse
45+
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-security main restricted universe multiverse
46+
deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-security main restricted universe multiverse
47+
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-proposed main restricted universe multiverse
48+
deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-proposed main restricted universe multiverse
49+
EOF
50+
;;
51+
"163")
52+
tee ${SOURCE_PATH} <<-'EOF'
53+
deb http://mirrors.163.com/ubuntu/ bionic main restricted universe multiverse
54+
deb http://mirrors.163.com/ubuntu/ bionic-security main restricted universe multiverse
55+
deb http://mirrors.163.com/ubuntu/ bionic-updates main restricted universe multiverse
56+
deb http://mirrors.163.com/ubuntu/ bionic-proposed main restricted universe multiverse
57+
deb http://mirrors.163.com/ubuntu/ bionic-backports main restricted universe multiverse
58+
deb-src http://mirrors.163.com/ubuntu/ bionic main restricted universe multiverse
59+
deb-src http://mirrors.163.com/ubuntu/ bionic-security main restricted universe multiverse
60+
deb-src http://mirrors.163.com/ubuntu/ bionic-updates main restricted universe multiverse
61+
deb-src http://mirrors.163.com/ubuntu/ bionic-proposed main restricted universe multiverse
62+
deb-src http://mirrors.163.com/ubuntu/ bionic-backports main restricted universe multiverse
63+
EOF
64+
;;
65+
"ustc")
66+
tee ${SOURCE_PATH} <<-'EOF'
67+
deb https://mirrors.ustc.edu.cn/ubuntu/ bionic main restricted universe multiverse
68+
deb-src https://mirrors.ustc.edu.cn/ubuntu/ bionic main restricted universe multiverse
69+
deb https://mirrors.ustc.edu.cn/ubuntu/ bionic-updates main restricted universe multiverse
70+
deb-src https://mirrors.ustc.edu.cn/ubuntu/ bionic-updates main restricted universe multiverse
71+
deb https://mirrors.ustc.edu.cn/ubuntu/ bionic-backports main restricted universe multiverse
72+
deb-src https://mirrors.ustc.edu.cn/ubuntu/ bionic-backports main restricted universe multiverse
73+
deb https://mirrors.ustc.edu.cn/ubuntu/ bionic-security main restricted universe multiverse
74+
deb-src https://mirrors.ustc.edu.cn/ubuntu/ bionic-security main restricted universe multiverse
75+
deb https://mirrors.ustc.edu.cn/ubuntu/ bionic-proposed main restricted universe multiverse
76+
deb-src https://mirrors.ustc.edu.cn/ubuntu/ bionic-proposed main restricted universe multiverse
77+
EOF
78+
;;
79+
*)
80+
echo "Please check whether there is aliyun|zju|tsinghua|163|ustc in the parameter"
81+
exit 1;;
82+
esac
83+
fi

0 commit comments

Comments
 (0)