From 4b5a1ef628245920f8d56172cb78a2a47df32761 Mon Sep 17 00:00:00 2001 From: Bolo Lai Date: Wed, 21 Feb 2018 13:13:19 +0800 Subject: [PATCH] support custom composer repo url and npm registry url --- docker-compose.yml | 2 ++ env-example | 2 ++ workspace/Dockerfile-56 | 23 +++++++++++++++++++++++ workspace/Dockerfile-70 | 23 +++++++++++++++++++++++ workspace/Dockerfile-71 | 22 ++++++++++++++++++++++ 5 files changed, 72 insertions(+) diff --git a/docker-compose.yml b/docker-compose.yml index d2fb4ae..95f857f 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -23,12 +23,14 @@ services: - INSTALL_PHPREDIS=${WORKSPACE_INSTALL_PHPREDIS} - INSTALL_MSSQL=${WORKSPACE_INSTALL_MSSQL} - INSTALL_NODE=${WORKSPACE_INSTALL_NODE} + - NPM_REGISTRY=${WORKSPACE_NPM_REGISTRY} - INSTALL_YARN=${WORKSPACE_INSTALL_YARN} - INSTALL_DRUSH=${WORKSPACE_INSTALL_DRUSH} - INSTALL_DRUPAL_CONSOLE=${WORKSPACE_INSTALL_DRUPAL_CONSOLE} - INSTALL_AEROSPIKE=${WORKSPACE_INSTALL_AEROSPIKE} - INSTALL_V8JS=${WORKSPACE_INSTALL_V8JS} - COMPOSER_GLOBAL_INSTALL=${WORKSPACE_COMPOSER_GLOBAL_INSTALL} + - COMPOSER_REPO_PACKAGIST=${WORKSPACE_COMPOSER_REPO_PACKAGIST} - INSTALL_WORKSPACE_SSH=${WORKSPACE_INSTALL_WORKSPACE_SSH} - INSTALL_LARAVEL_ENVOY=${WORKSPACE_INSTALL_LARAVEL_ENVOY} - INSTALL_LARAVEL_INSTALLER=${WORKSPACE_INSTALL_LARAVEL_INSTALLER} diff --git a/env-example b/env-example index c3d103d..80ac895 100644 --- a/env-example +++ b/env-example @@ -67,12 +67,14 @@ WORKSPACE_INSTALL_AMQP=false WORKSPACE_INSTALL_PHPREDIS=false WORKSPACE_INSTALL_MSSQL=false WORKSPACE_INSTALL_NODE=false +WORKSPACE_NPM_REGISTRY= WORKSPACE_INSTALL_YARN=false WORKSPACE_INSTALL_DRUSH=false WORKSPACE_INSTALL_DRUPAL_CONSOLE=false WORKSPACE_INSTALL_AEROSPIKE=false WORKSPACE_INSTALL_V8JS=false WORKSPACE_COMPOSER_GLOBAL_INSTALL=false +WORKSPACE_COMPOSER_REPO_PACKAGIST= WORKSPACE_INSTALL_WORKSPACE_SSH=false WORKSPACE_INSTALL_LARAVEL_ENVOY=false WORKSPACE_INSTALL_LARAVEL_INSTALLER=false diff --git a/workspace/Dockerfile-56 b/workspace/Dockerfile-56 index e3a911c..c95dfed 100644 --- a/workspace/Dockerfile-56 +++ b/workspace/Dockerfile-56 @@ -127,6 +127,13 @@ RUN if [ ${COMPOSER_GLOBAL_INSTALL} = true ]; then \ composer global install \ ;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 RUN echo "" >> ~/.bashrc && \ echo 'export PATH="~/.composer/vendor/bin:$PATH"' >> ~/.bashrc @@ -309,6 +316,8 @@ ARG NODE_VERSION=stable ENV NODE_VERSION ${NODE_VERSION} ARG INSTALL_NODE=false ENV INSTALL_NODE ${INSTALL_NODE} +ARG NPM_REGISTRY +ENV NPM_REGISTRY ${NPM_REGISTRY} ENV NVM_DIR /home/laradock/.nvm RUN if [ ${INSTALL_NODE} = true ]; then \ # Install nvm (A Node Version Manager) @@ -317,6 +326,9 @@ RUN if [ ${INSTALL_NODE} = true ]; then \ nvm install ${NODE_VERSION} && \ nvm use ${NODE_VERSION} && \ nvm alias ${NODE_VERSION} && \ + if [ ${NPM_REGISTRY} ]; then \ + npm config set registry ${NPM_REGISTRY} \ + ;fi && \ npm install -g gulp bower vue-cli \ ;fi @@ -340,6 +352,10 @@ RUN if [ ${INSTALL_NODE} = true ]; then \ # Add PATH for node 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: ##################################### @@ -428,6 +444,13 @@ RUN if [ ${INSTALL_LARAVEL_ENVOY} = true ]; then \ ##################################### 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 ENV INSTALL_LARAVEL_INSTALLER ${INSTALL_LARAVEL_INSTALLER} diff --git a/workspace/Dockerfile-70 b/workspace/Dockerfile-70 index d815278..bfb0fba 100644 --- a/workspace/Dockerfile-70 +++ b/workspace/Dockerfile-70 @@ -124,6 +124,13 @@ RUN if [ ${COMPOSER_GLOBAL_INSTALL} = true ]; then \ composer global install \ ;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 RUN echo "" >> ~/.bashrc && \ echo 'export PATH="~/.composer/vendor/bin:$PATH"' >> ~/.bashrc @@ -305,6 +312,8 @@ ARG NODE_VERSION=stable ENV NODE_VERSION ${NODE_VERSION} ARG INSTALL_NODE=false ENV INSTALL_NODE ${INSTALL_NODE} +ARG NPM_REGISTRY +ENV NPM_REGISTRY ${NPM_REGISTRY} ENV NVM_DIR /home/laradock/.nvm RUN if [ ${INSTALL_NODE} = true ]; then \ # Install nvm (A Node Version Manager) @@ -313,6 +322,9 @@ RUN if [ ${INSTALL_NODE} = true ]; then \ nvm install ${NODE_VERSION} && \ nvm use ${NODE_VERSION} && \ nvm alias ${NODE_VERSION} && \ + if [ ${NPM_REGISTRY} ]; then \ + npm config set registry ${NPM_REGISTRY} \ + ;fi && \ npm install -g gulp bower vue-cli \ ;fi @@ -336,6 +348,10 @@ RUN if [ ${INSTALL_NODE} = true ]; then \ # Add PATH for node 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: ##################################### @@ -441,6 +457,13 @@ RUN if [ ${INSTALL_LARAVEL_ENVOY} = true ]; then \ ##################################### 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 ENV INSTALL_LARAVEL_INSTALLER ${INSTALL_LARAVEL_INSTALLER} diff --git a/workspace/Dockerfile-71 b/workspace/Dockerfile-71 index 3a1a0ab..24234cd 100644 --- a/workspace/Dockerfile-71 +++ b/workspace/Dockerfile-71 @@ -123,6 +123,13 @@ RUN if [ ${COMPOSER_GLOBAL_INSTALL} = true ]; then \ composer global install \ ;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 ##################################### @@ -301,6 +308,8 @@ ARG NODE_VERSION=stable ENV NODE_VERSION ${NODE_VERSION} ARG INSTALL_NODE=false ENV INSTALL_NODE ${INSTALL_NODE} +ARG NPM_REGISTRY +ENV NPM_REGISTRY ${NPM_REGISTRY} ENV NVM_DIR /home/laradock/.nvm RUN if [ ${INSTALL_NODE} = true ]; then \ # Install nvm (A Node Version Manager) @@ -309,6 +318,9 @@ RUN if [ ${INSTALL_NODE} = true ]; then \ nvm install ${NODE_VERSION} && \ nvm use ${NODE_VERSION} && \ nvm alias ${NODE_VERSION} && \ + if [ ${NPM_REGISTRY} ]; then \ + npm config set registry ${NPM_REGISTRY} \ + ;fi && \ npm install -g gulp bower vue-cli \ ;fi @@ -332,6 +344,9 @@ RUN if [ ${INSTALL_NODE} = true ]; then \ # Add PATH for node 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: @@ -442,6 +457,13 @@ RUN if [ ${INSTALL_LARAVEL_ENVOY} = true ]; then \ ##################################### 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 ENV INSTALL_LARAVEL_INSTALLER ${INSTALL_LARAVEL_INSTALLER}