From b6204e5933e8a7173ce143432fe20fe8150e034a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=89=9F=E5=8B=87?= Date: Thu, 5 Dec 2019 11:16:32 +0800 Subject: [PATCH] pref: add change source flag --- docker-compose.yml | 4 +++- laravel-horizon/Dockerfile | 10 +++++++++- php-worker/Dockerfile | 8 ++++++++ 3 files changed, 20 insertions(+), 2 deletions(-) diff --git a/docker-compose.yml b/docker-compose.yml index b0b297c7..acbe2264 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -234,6 +234,7 @@ services: build: context: ./php-worker args: + - CHANGE_SOURCE=${CHANGE_SOURCE} - PHP_VERSION=${PHP_VERSION} - PHALCON_VERSION=${PHALCON_VERSION} - INSTALL_PGSQL=${PHP_WORKER_INSTALL_PGSQL} @@ -267,6 +268,7 @@ services: build: context: ./laravel-horizon args: + - CHANGE_SOURCE=${CHANGE_SOURCE} - PHP_VERSION=${PHP_VERSION} - INSTALL_PGSQL=${PHP_FPM_INSTALL_PGSQL} - INSTALL_BCMATH=${PHP_FPM_INSTALL_BCMATH} @@ -290,9 +292,9 @@ services: build: context: ./nginx args: + - CHANGE_SOURCE=${CHANGE_SOURCE} - PHP_UPSTREAM_CONTAINER=${NGINX_PHP_UPSTREAM_CONTAINER} - PHP_UPSTREAM_PORT=${NGINX_PHP_UPSTREAM_PORT} - - CHANGE_SOURCE=${CHANGE_SOURCE} - http_proxy - https_proxy - no_proxy diff --git a/laravel-horizon/Dockerfile b/laravel-horizon/Dockerfile index 425499d6..9edbe14b 100644 --- a/laravel-horizon/Dockerfile +++ b/laravel-horizon/Dockerfile @@ -9,6 +9,14 @@ FROM php:${PHP_VERSION}-alpine LABEL maintainer="Mahmoud Zalt " +# If you're in China, or you need to change sources, will be set CHANGE_SOURCE to true in .env. + +ARG CHANGE_SOURCE=false +RUN if [ ${CHANGE_SOURCE} = true ]; then \ + # Change application source from dl-cdn.alpinelinux.org to aliyun source + sed -i 's/dl-cdn.alpinelinux.org/mirrors.aliyun.com/' /etc/apk/repositories \ +;fi + RUN apk --update add wget \ curl \ git \ @@ -50,7 +58,7 @@ ARG INSTALL_CASSANDRA=false RUN if [ ${INSTALL_CASSANDRA} = true ]; then \ apk --update add cassandra-cpp-driver \ ;fi - + # Install PhpRedis package: ARG INSTALL_PHPREDIS=false RUN if [ ${INSTALL_PHPREDIS} = true ]; then \ diff --git a/php-worker/Dockerfile b/php-worker/Dockerfile index 9bccca0e..350c40dc 100644 --- a/php-worker/Dockerfile +++ b/php-worker/Dockerfile @@ -9,6 +9,14 @@ FROM php:${PHP_VERSION}-alpine LABEL maintainer="Mahmoud Zalt " +# If you're in China, or you need to change sources, will be set CHANGE_SOURCE to true in .env. + +ARG CHANGE_SOURCE=false +RUN if [ ${CHANGE_SOURCE} = true ]; then \ + # Change application source from dl-cdn.alpinelinux.org to aliyun source + sed -i 's/dl-cdn.alpinelinux.org/mirrors.aliyun.com/' /etc/apk/repositories \ +;fi + RUN apk --update add wget \ curl \ git \