Merge pull request #1387 from CantonBolo/optimize

Support custom composer repo url and npm registry url
This commit is contained in:
Yu-Lung Shao (Allen) 2018-02-22 10:08:15 +08:00 committed by GitHub
commit 13f55ef796
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 82 additions and 0 deletions

View File

@ -1729,3 +1729,13 @@ This error sometimes happens because your Laravel application isn't running on t
## I get stuck when building nginx on `fetch http://mirrors.aliyun.com/alpine/v3.5/main/x86_64/APKINDEX.tar.gz` ## I get stuck when building nginx on `fetch http://mirrors.aliyun.com/alpine/v3.5/main/x86_64/APKINDEX.tar.gz`
As stated on [#749](https://github.com/laradock/laradock/issues/749#issuecomment-293296687), removing the line `RUN sed -i 's/dl-cdn.alpinelinux.org/mirrors.aliyun.com/' /etc/apk/repositories` from `nginx/Dockerfile` solves the problem. As stated on [#749](https://github.com/laradock/laradock/issues/749#issuecomment-293296687), removing the line `RUN sed -i 's/dl-cdn.alpinelinux.org/mirrors.aliyun.com/' /etc/apk/repositories` from `nginx/Dockerfile` solves the problem.
## Custom composer repo packagist url and npm registry url
In China, the origin source of composer and npm is very slow. You can add `WORKSPACE_NPM_REGISTRY` and `WORKSPACE_COMPOSER_REPO_PACKAGIST` config in `.env` to use your custom source.
Example:
```bash
WORKSPACE_NPM_REGISTRY=https://registry.npm.taobao.org
WORKSPACE_COMPOSER_REPO_PACKAGIST=https://packagist.phpcomposer.com
```

View File

@ -23,12 +23,14 @@ services:
- INSTALL_PHPREDIS=${WORKSPACE_INSTALL_PHPREDIS} - INSTALL_PHPREDIS=${WORKSPACE_INSTALL_PHPREDIS}
- INSTALL_MSSQL=${WORKSPACE_INSTALL_MSSQL} - INSTALL_MSSQL=${WORKSPACE_INSTALL_MSSQL}
- INSTALL_NODE=${WORKSPACE_INSTALL_NODE} - INSTALL_NODE=${WORKSPACE_INSTALL_NODE}
- NPM_REGISTRY=${WORKSPACE_NPM_REGISTRY}
- INSTALL_YARN=${WORKSPACE_INSTALL_YARN} - INSTALL_YARN=${WORKSPACE_INSTALL_YARN}
- INSTALL_DRUSH=${WORKSPACE_INSTALL_DRUSH} - INSTALL_DRUSH=${WORKSPACE_INSTALL_DRUSH}
- INSTALL_DRUPAL_CONSOLE=${WORKSPACE_INSTALL_DRUPAL_CONSOLE} - INSTALL_DRUPAL_CONSOLE=${WORKSPACE_INSTALL_DRUPAL_CONSOLE}
- INSTALL_AEROSPIKE=${WORKSPACE_INSTALL_AEROSPIKE} - INSTALL_AEROSPIKE=${WORKSPACE_INSTALL_AEROSPIKE}
- INSTALL_V8JS=${WORKSPACE_INSTALL_V8JS} - INSTALL_V8JS=${WORKSPACE_INSTALL_V8JS}
- COMPOSER_GLOBAL_INSTALL=${WORKSPACE_COMPOSER_GLOBAL_INSTALL} - COMPOSER_GLOBAL_INSTALL=${WORKSPACE_COMPOSER_GLOBAL_INSTALL}
- COMPOSER_REPO_PACKAGIST=${WORKSPACE_COMPOSER_REPO_PACKAGIST}
- INSTALL_WORKSPACE_SSH=${WORKSPACE_INSTALL_WORKSPACE_SSH} - INSTALL_WORKSPACE_SSH=${WORKSPACE_INSTALL_WORKSPACE_SSH}
- INSTALL_LARAVEL_ENVOY=${WORKSPACE_INSTALL_LARAVEL_ENVOY} - INSTALL_LARAVEL_ENVOY=${WORKSPACE_INSTALL_LARAVEL_ENVOY}
- INSTALL_LARAVEL_INSTALLER=${WORKSPACE_INSTALL_LARAVEL_INSTALLER} - INSTALL_LARAVEL_INSTALLER=${WORKSPACE_INSTALL_LARAVEL_INSTALLER}

View File

@ -67,12 +67,14 @@ WORKSPACE_INSTALL_AMQP=false
WORKSPACE_INSTALL_PHPREDIS=false WORKSPACE_INSTALL_PHPREDIS=false
WORKSPACE_INSTALL_MSSQL=false WORKSPACE_INSTALL_MSSQL=false
WORKSPACE_INSTALL_NODE=false WORKSPACE_INSTALL_NODE=false
WORKSPACE_NPM_REGISTRY=
WORKSPACE_INSTALL_YARN=false WORKSPACE_INSTALL_YARN=false
WORKSPACE_INSTALL_DRUSH=false WORKSPACE_INSTALL_DRUSH=false
WORKSPACE_INSTALL_DRUPAL_CONSOLE=false WORKSPACE_INSTALL_DRUPAL_CONSOLE=false
WORKSPACE_INSTALL_AEROSPIKE=false WORKSPACE_INSTALL_AEROSPIKE=false
WORKSPACE_INSTALL_V8JS=false WORKSPACE_INSTALL_V8JS=false
WORKSPACE_COMPOSER_GLOBAL_INSTALL=false WORKSPACE_COMPOSER_GLOBAL_INSTALL=false
WORKSPACE_COMPOSER_REPO_PACKAGIST=
WORKSPACE_INSTALL_WORKSPACE_SSH=false WORKSPACE_INSTALL_WORKSPACE_SSH=false
WORKSPACE_INSTALL_LARAVEL_ENVOY=false WORKSPACE_INSTALL_LARAVEL_ENVOY=false
WORKSPACE_INSTALL_LARAVEL_INSTALLER=false WORKSPACE_INSTALL_LARAVEL_INSTALLER=false

View File

@ -127,6 +127,13 @@ RUN if [ ${COMPOSER_GLOBAL_INSTALL} = true ]; then \
composer global install \ composer global install \
;fi ;fi
ARG COMPOSER_REPO_PACKAGIST
ENV COMPOSER_REPO_PACKAGIST ${COMPOSER_REPO_PACKAGIST}
RUN if [ ${COMPOSER_REPO_PACKAGIST} ]; then \
composer config -g repo.packagist composer ${COMPOSER_REPO_PACKAGIST} \
;fi
# Export composer vendor path # Export composer vendor path
RUN echo "" >> ~/.bashrc && \ RUN echo "" >> ~/.bashrc && \
echo 'export PATH="~/.composer/vendor/bin:$PATH"' >> ~/.bashrc echo 'export PATH="~/.composer/vendor/bin:$PATH"' >> ~/.bashrc
@ -309,6 +316,8 @@ ARG NODE_VERSION=stable
ENV NODE_VERSION ${NODE_VERSION} ENV NODE_VERSION ${NODE_VERSION}
ARG INSTALL_NODE=false ARG INSTALL_NODE=false
ENV INSTALL_NODE ${INSTALL_NODE} ENV INSTALL_NODE ${INSTALL_NODE}
ARG NPM_REGISTRY
ENV NPM_REGISTRY ${NPM_REGISTRY}
ENV NVM_DIR /home/laradock/.nvm ENV NVM_DIR /home/laradock/.nvm
RUN if [ ${INSTALL_NODE} = true ]; then \ RUN if [ ${INSTALL_NODE} = true ]; then \
# Install nvm (A Node Version Manager) # Install nvm (A Node Version Manager)
@ -317,6 +326,9 @@ RUN if [ ${INSTALL_NODE} = true ]; then \
nvm install ${NODE_VERSION} && \ nvm install ${NODE_VERSION} && \
nvm use ${NODE_VERSION} && \ nvm use ${NODE_VERSION} && \
nvm alias ${NODE_VERSION} && \ nvm alias ${NODE_VERSION} && \
if [ ${NPM_REGISTRY} ]; then \
npm config set registry ${NPM_REGISTRY} \
;fi && \
npm install -g gulp bower vue-cli \ npm install -g gulp bower vue-cli \
;fi ;fi
@ -340,6 +352,10 @@ RUN if [ ${INSTALL_NODE} = true ]; then \
# Add PATH for node # Add PATH for node
ENV PATH $PATH:$NVM_DIR/versions/node/v${NODE_VERSION}/bin ENV PATH $PATH:$NVM_DIR/versions/node/v${NODE_VERSION}/bin
RUN if [ ${NPM_REGISTRY} ]; then \
. ~/.bashrc && npm config set registry ${NPM_REGISTRY} \
;fi
##################################### #####################################
# YARN: # YARN:
##################################### #####################################
@ -428,6 +444,13 @@ RUN if [ ${INSTALL_LARAVEL_ENVOY} = true ]; then \
##################################### #####################################
USER root USER root
ARG COMPOSER_REPO_PACKAGIST
ENV COMPOSER_REPO_PACKAGIST ${COMPOSER_REPO_PACKAGIST}
RUN if [ ${COMPOSER_REPO_PACKAGIST} ]; then \
composer config -g repo.packagist composer ${COMPOSER_REPO_PACKAGIST} \
;fi
ARG INSTALL_LARAVEL_INSTALLER=true ARG INSTALL_LARAVEL_INSTALLER=true
ENV INSTALL_LARAVEL_INSTALLER ${INSTALL_LARAVEL_INSTALLER} ENV INSTALL_LARAVEL_INSTALLER ${INSTALL_LARAVEL_INSTALLER}

View File

@ -124,6 +124,13 @@ RUN if [ ${COMPOSER_GLOBAL_INSTALL} = true ]; then \
composer global install \ composer global install \
;fi ;fi
ARG COMPOSER_REPO_PACKAGIST
ENV COMPOSER_REPO_PACKAGIST ${COMPOSER_REPO_PACKAGIST}
RUN if [ ${COMPOSER_REPO_PACKAGIST} ]; then \
composer config -g repo.packagist composer ${COMPOSER_REPO_PACKAGIST} \
;fi
# Export composer vendor path # Export composer vendor path
RUN echo "" >> ~/.bashrc && \ RUN echo "" >> ~/.bashrc && \
echo 'export PATH="~/.composer/vendor/bin:$PATH"' >> ~/.bashrc echo 'export PATH="~/.composer/vendor/bin:$PATH"' >> ~/.bashrc
@ -305,6 +312,8 @@ ARG NODE_VERSION=stable
ENV NODE_VERSION ${NODE_VERSION} ENV NODE_VERSION ${NODE_VERSION}
ARG INSTALL_NODE=false ARG INSTALL_NODE=false
ENV INSTALL_NODE ${INSTALL_NODE} ENV INSTALL_NODE ${INSTALL_NODE}
ARG NPM_REGISTRY
ENV NPM_REGISTRY ${NPM_REGISTRY}
ENV NVM_DIR /home/laradock/.nvm ENV NVM_DIR /home/laradock/.nvm
RUN if [ ${INSTALL_NODE} = true ]; then \ RUN if [ ${INSTALL_NODE} = true ]; then \
# Install nvm (A Node Version Manager) # Install nvm (A Node Version Manager)
@ -313,6 +322,9 @@ RUN if [ ${INSTALL_NODE} = true ]; then \
nvm install ${NODE_VERSION} && \ nvm install ${NODE_VERSION} && \
nvm use ${NODE_VERSION} && \ nvm use ${NODE_VERSION} && \
nvm alias ${NODE_VERSION} && \ nvm alias ${NODE_VERSION} && \
if [ ${NPM_REGISTRY} ]; then \
npm config set registry ${NPM_REGISTRY} \
;fi && \
npm install -g gulp bower vue-cli \ npm install -g gulp bower vue-cli \
;fi ;fi
@ -336,6 +348,10 @@ RUN if [ ${INSTALL_NODE} = true ]; then \
# Add PATH for node # Add PATH for node
ENV PATH $PATH:$NVM_DIR/versions/node/v${NODE_VERSION}/bin ENV PATH $PATH:$NVM_DIR/versions/node/v${NODE_VERSION}/bin
RUN if [ ${NPM_REGISTRY} ]; then \
. ~/.bashrc && npm config set registry ${NPM_REGISTRY} \
;fi
##################################### #####################################
# YARN: # YARN:
##################################### #####################################
@ -441,6 +457,13 @@ RUN if [ ${INSTALL_LARAVEL_ENVOY} = true ]; then \
##################################### #####################################
USER root USER root
ARG COMPOSER_REPO_PACKAGIST
ENV COMPOSER_REPO_PACKAGIST ${COMPOSER_REPO_PACKAGIST}
RUN if [ ${COMPOSER_REPO_PACKAGIST} ]; then \
composer config -g repo.packagist composer ${COMPOSER_REPO_PACKAGIST} \
;fi
ARG INSTALL_LARAVEL_INSTALLER=true ARG INSTALL_LARAVEL_INSTALLER=true
ENV INSTALL_LARAVEL_INSTALLER ${INSTALL_LARAVEL_INSTALLER} ENV INSTALL_LARAVEL_INSTALLER ${INSTALL_LARAVEL_INSTALLER}

View File

@ -123,6 +123,13 @@ RUN if [ ${COMPOSER_GLOBAL_INSTALL} = true ]; then \
composer global install \ composer global install \
;fi ;fi
ARG COMPOSER_REPO_PACKAGIST
ENV COMPOSER_REPO_PACKAGIST ${COMPOSER_REPO_PACKAGIST}
RUN if [ ${COMPOSER_REPO_PACKAGIST} ]; then \
composer config -g repo.packagist composer ${COMPOSER_REPO_PACKAGIST} \
;fi
##################################### #####################################
# Crontab # Crontab
##################################### #####################################
@ -301,6 +308,8 @@ ARG NODE_VERSION=stable
ENV NODE_VERSION ${NODE_VERSION} ENV NODE_VERSION ${NODE_VERSION}
ARG INSTALL_NODE=false ARG INSTALL_NODE=false
ENV INSTALL_NODE ${INSTALL_NODE} ENV INSTALL_NODE ${INSTALL_NODE}
ARG NPM_REGISTRY
ENV NPM_REGISTRY ${NPM_REGISTRY}
ENV NVM_DIR /home/laradock/.nvm ENV NVM_DIR /home/laradock/.nvm
RUN if [ ${INSTALL_NODE} = true ]; then \ RUN if [ ${INSTALL_NODE} = true ]; then \
# Install nvm (A Node Version Manager) # Install nvm (A Node Version Manager)
@ -309,6 +318,9 @@ RUN if [ ${INSTALL_NODE} = true ]; then \
nvm install ${NODE_VERSION} && \ nvm install ${NODE_VERSION} && \
nvm use ${NODE_VERSION} && \ nvm use ${NODE_VERSION} && \
nvm alias ${NODE_VERSION} && \ nvm alias ${NODE_VERSION} && \
if [ ${NPM_REGISTRY} ]; then \
npm config set registry ${NPM_REGISTRY} \
;fi && \
npm install -g gulp bower vue-cli \ npm install -g gulp bower vue-cli \
;fi ;fi
@ -332,6 +344,9 @@ RUN if [ ${INSTALL_NODE} = true ]; then \
# Add PATH for node # Add PATH for node
ENV PATH $PATH:$NVM_DIR/versions/node/v${NODE_VERSION}/bin ENV PATH $PATH:$NVM_DIR/versions/node/v${NODE_VERSION}/bin
RUN if [ ${NPM_REGISTRY} ]; then \
. ~/.bashrc && npm config set registry ${NPM_REGISTRY} \
;fi
##################################### #####################################
# YARN: # YARN:
@ -442,6 +457,13 @@ RUN if [ ${INSTALL_LARAVEL_ENVOY} = true ]; then \
##################################### #####################################
USER root USER root
ARG COMPOSER_REPO_PACKAGIST
ENV COMPOSER_REPO_PACKAGIST ${COMPOSER_REPO_PACKAGIST}
RUN if [ ${COMPOSER_REPO_PACKAGIST} ]; then \
composer config -g repo.packagist composer ${COMPOSER_REPO_PACKAGIST} \
;fi
ARG INSTALL_LARAVEL_INSTALLER=false ARG INSTALL_LARAVEL_INSTALLER=false
ENV INSTALL_LARAVEL_INSTALLER ${INSTALL_LARAVEL_INSTALLER} ENV INSTALL_LARAVEL_INSTALLER ${INSTALL_LARAVEL_INSTALLER}