From 567082a42510fea936104d7078981be2d6b54288 Mon Sep 17 00:00:00 2001 From: Leonid Makarov Date: Thu, 31 May 2018 00:29:15 -0700 Subject: [PATCH 01/45] Switch to global Node.js installation - Ditch nvm and install Node.js globally from NodeSource repos - List images after build (to check image sizes) --- .travis.yml | 2 ++ 5.6/Dockerfile | 49 +++++++++++++++++++----------------------- 5.6/config/.docksalrc | 4 ---- 7.0/Dockerfile | 50 ++++++++++++++++++------------------------- 7.0/config/.docksalrc | 4 ---- 7.1/Dockerfile | 50 ++++++++++++++++++------------------------- 7.1/config/.docksalrc | 4 ---- 7.2/Dockerfile | 50 ++++++++++++++++++------------------------- 7.2/config/.docksalrc | 4 ---- README.md | 3 +-- 10 files changed, 88 insertions(+), 132 deletions(-) diff --git a/.travis.yml b/.travis.yml index eddcabd3..8d7d8198 100644 --- a/.travis.yml +++ b/.travis.yml @@ -27,6 +27,8 @@ script: - travis_retry make && make test # Retry builds, as pecl.php.net tends to time out often after_success: | + docker image ls + if [[ "${TRAVIS_PULL_REQUEST}" == "false" ]]; then [[ "${TRAVIS_BRANCH}" == "develop" ]] && TAG="edge-php${VERSION}" [[ "${TRAVIS_BRANCH}" == "master" ]] && TAG="php${VERSION}" diff --git a/5.6/Dockerfile b/5.6/Dockerfile index 2a6d61d7..8026ccbb 100644 --- a/5.6/Dockerfile +++ b/5.6/Dockerfile @@ -47,10 +47,7 @@ RUN set -xe; \ # git-lfs repo curl -sSL https://packagecloud.io/github/git-lfs/gpgkey | apt-key add -; \ echo 'deb https://packagecloud.io/github/git-lfs/debian/ jessie main' | tee /etc/apt/sources.list.d/github_git-lfs.list; \ - echo 'deb-src https://packagecloud.io/github/git-lfs/debian/ jessie main' | tee -a /etc/apt/sources.list.d/github_git-lfs.list; \ - # yarn repo - curl -sSL https://dl.yarnpkg.com/debian/pubkey.gpg | apt-key add -; \ - echo "deb https://dl.yarnpkg.com/debian/ stable main" | tee /etc/apt/sources.list.d/yarn.list + echo 'deb-src https://packagecloud.io/github/git-lfs/debian/ jessie main' | tee -a /etc/apt/sources.list.d/github_git-lfs.list; # Additional packages RUN set -xe; \ @@ -114,7 +111,7 @@ RUN set -xe; \ echo "export VISIBLE=now" >> /etc/profile ENV NOTVISIBLE "in users profile" -# Install PHP extentions +# PHP RUN set -xe; \ buildDeps=" \ freetds-dev \ @@ -245,17 +242,30 @@ RUN set -xe; \ # Make all binaries executable in one shot chmod +x /usr/local/bin/* -# Other language packages and dependencies +# Node.js +ENV NODE_VERSION=8.x +RUN set -xe; \ + # Node.js repo + curl -sSL https://deb.nodesource.com/gpgkey/nodesource.gpg.key | apt-key add -; \ + echo "deb https://deb.nodesource.com/node_${NODE_VERSION} jessie main" | sudo tee /etc/apt/sources.list.d/nodesource.list; \ + echo "deb-src https://deb.nodesource.com/node_${NODE_VERSION} jessie main" | sudo tee -a /etc/apt/sources.list.d/nodesource.list; \ + # yarn repo + curl -sSL https://dl.yarnpkg.com/debian/pubkey.gpg | apt-key add -; \ + echo "deb https://dl.yarnpkg.com/debian/ stable main" | tee /etc/apt/sources.list.d/yarn.list; \ + apt-get update >/dev/null; apt-get -y --force-yes --no-install-recommends install >/dev/null \ + nodejs; \ + apt-get clean; rm -rf /var/lib/apt/lists/*; + +# Ruby RUN set -xe; \ apt-get update >/dev/null; apt-get -y --force-yes --no-install-recommends install >/dev/null \ ruby-full \ rlwrap; \ #build-essential; \ # Cleanup - apt-get clean; rm -rf /var/lib/apt/lists/* - -# bundler -RUN gem install bundler >/dev/null + apt-get clean; rm -rf /var/lib/apt/lists/*; \ + # bundler + gem install bundler >/dev/null # Home directory for bundle installs ENV BUNDLE_PATH .bundler @@ -263,23 +273,6 @@ ENV BUNDLE_PATH .bundler USER docker ENV HOME /home/docker -# Install nvm and a default node version -ENV NVM_VERSION=0.33.8 \ - NODE_VERSION=8.11.0 \ - NVM_DIR=$HOME/.nvm -# Don't use -x here - node/nvm stuff prints just too much stuff -RUN set -e; \ - curl -sSL https://raw.githubusercontent.com/creationix/nvm/v${NVM_VERSION}/install.sh | bash; \ - . $NVM_DIR/nvm.sh; \ - nvm install $NODE_VERSION >/dev/null; \ - nvm alias default $NODE_VERSION; \ - # Install global node packages - npm install -g npm >/dev/null; \ - # Cleanup - nvm clear-cache && npm cache clear --force; \ - # Fix npm complaining about permissions and not being able to update - sudo rm -rf $HOME/.config - # Install Composer based dependencies ENV PATH=$PATH:$HOME/.composer/vendor/bin \ DRUSH_LAUNCHER_FALLBACK=/usr/local/bin/drush8 @@ -307,6 +300,8 @@ RUN set -xe; \ USER root +# Copy mhsendmail binary from stage 1 +COPY --from=mhbuild /go/bin/mhsendmail /usr/local/bin/mhsendmail # Copy configs and scripts COPY --chown=docker:docker config/.acquia $HOME/.acquia COPY --chown=docker:docker config/.docksalrc $HOME/.docksalrc diff --git a/5.6/config/.docksalrc b/5.6/config/.docksalrc index 576167b7..40f7428b 100644 --- a/5.6/config/.docksalrc +++ b/5.6/config/.docksalrc @@ -3,10 +3,6 @@ # Allow alias expansion in non-interactive shells. shopt -s expand_aliases -# NVM initialization. -export NVM_DIR="/home/docker/.nvm" -[ -s "$NVM_DIR/nvm.sh" ] && . "$NVM_DIR/nvm.sh" # This loads nvm - # Source alias definitions. if [ -f ~/.bash_aliases ]; then . ~/.bash_aliases diff --git a/7.0/Dockerfile b/7.0/Dockerfile index ae314a24..123c912c 100644 --- a/7.0/Dockerfile +++ b/7.0/Dockerfile @@ -48,9 +48,6 @@ RUN set -xe; \ curl -sSL https://packagecloud.io/github/git-lfs/gpgkey | apt-key add -; \ echo 'deb https://packagecloud.io/github/git-lfs/debian/ jessie main' | tee /etc/apt/sources.list.d/github_git-lfs.list; \ echo 'deb-src https://packagecloud.io/github/git-lfs/debian/ jessie main' | tee -a /etc/apt/sources.list.d/github_git-lfs.list; \ - # yarn repo - curl -sSL https://dl.yarnpkg.com/debian/pubkey.gpg | apt-key add -; \ - echo "deb https://dl.yarnpkg.com/debian/ stable main" | tee /etc/apt/sources.list.d/yarn.list; \ # MSQSQL repo - msodbcsql17, pecl/sqlsrv and pecl/pdo_sqlsrv (PHP 7.0+ only) curl -sSL https://packages.microsoft.com/keys/microsoft.asc | apt-key add -; \ echo 'deb https://packages.microsoft.com/debian/8/prod jessie main' | tee /etc/apt/sources.list.d/mssql.list; @@ -117,7 +114,7 @@ RUN set -xe; \ echo "export VISIBLE=now" >> /etc/profile ENV NOTVISIBLE "in users profile" -# Install PHP extentions +# PHP RUN set -xe; \ buildDeps=" \ g++ \ @@ -223,9 +220,6 @@ RUN set -xe; \ apt-get purge -y --auto-remove -o APT::AutoRemove::RecommendsImportant=false $buildDeps >/dev/null; \ apt-get clean; rm -rf /var/lib/apt/lists/* -# Copy mhsendmail binary from stage 1 -COPY --from=mhbuild /go/bin/mhsendmail /usr/local/bin/mhsendmail - ENV COMPOSER_VERSION=1.6.3 \ DRUSH_VERSION=8.1.16 \ DRUSH_LAUNCHER_VERSION=0.6.0 \ @@ -254,17 +248,30 @@ RUN set -xe; \ # Make all binaries executable in one shot chmod +x /usr/local/bin/* -# Other language packages and dependencies +# Node.js +ENV NODE_VERSION=8.x +RUN set -xe; \ + # Node.js repo + curl -sSL https://deb.nodesource.com/gpgkey/nodesource.gpg.key | apt-key add -; \ + echo "deb https://deb.nodesource.com/node_${NODE_VERSION} jessie main" | sudo tee /etc/apt/sources.list.d/nodesource.list; \ + echo "deb-src https://deb.nodesource.com/node_${NODE_VERSION} jessie main" | sudo tee -a /etc/apt/sources.list.d/nodesource.list; \ + # yarn repo + curl -sSL https://dl.yarnpkg.com/debian/pubkey.gpg | apt-key add -; \ + echo "deb https://dl.yarnpkg.com/debian/ stable main" | tee /etc/apt/sources.list.d/yarn.list; \ + apt-get update >/dev/null; apt-get -y --force-yes --no-install-recommends install >/dev/null \ + nodejs; \ + apt-get clean; rm -rf /var/lib/apt/lists/*; + +# Ruby RUN set -xe; \ apt-get update >/dev/null; apt-get -y --force-yes --no-install-recommends install >/dev/null \ ruby-full \ rlwrap; \ #build-essential; \ # Cleanup - apt-get clean; rm -rf /var/lib/apt/lists/* - -# bundler -RUN gem install bundler >/dev/null + apt-get clean; rm -rf /var/lib/apt/lists/*; \ + # bundler + gem install bundler >/dev/null # Home directory for bundle installs ENV BUNDLE_PATH .bundler @@ -272,23 +279,6 @@ ENV BUNDLE_PATH .bundler USER docker ENV HOME /home/docker -# Install nvm and a default node version -ENV NVM_VERSION=0.33.8 \ - NODE_VERSION=8.11.0 \ - NVM_DIR=$HOME/.nvm -# Don't use -x here - node/nvm stuff prints just too much stuff -RUN set -e; \ - curl -sSL https://raw.githubusercontent.com/creationix/nvm/v${NVM_VERSION}/install.sh | bash; \ - . $NVM_DIR/nvm.sh; \ - nvm install $NODE_VERSION >/dev/null; \ - nvm alias default $NODE_VERSION; \ - # Install global node packages - npm install -g npm >/dev/null; \ - # Cleanup - nvm clear-cache && npm cache clear --force; \ - # Fix npm complaining about permissions and not being able to update - sudo rm -rf $HOME/.config - # Install Composer based dependencies ENV PATH=$PATH:$HOME/.composer/vendor/bin \ DRUSH_LAUNCHER_FALLBACK=/usr/local/bin/drush8 @@ -316,6 +306,8 @@ RUN set -xe; \ USER root +# Copy mhsendmail binary from stage 1 +COPY --from=mhbuild /go/bin/mhsendmail /usr/local/bin/mhsendmail # Copy configs and scripts COPY --chown=docker:docker config/.acquia $HOME/.acquia COPY --chown=docker:docker config/.docksalrc $HOME/.docksalrc diff --git a/7.0/config/.docksalrc b/7.0/config/.docksalrc index 576167b7..40f7428b 100644 --- a/7.0/config/.docksalrc +++ b/7.0/config/.docksalrc @@ -3,10 +3,6 @@ # Allow alias expansion in non-interactive shells. shopt -s expand_aliases -# NVM initialization. -export NVM_DIR="/home/docker/.nvm" -[ -s "$NVM_DIR/nvm.sh" ] && . "$NVM_DIR/nvm.sh" # This loads nvm - # Source alias definitions. if [ -f ~/.bash_aliases ]; then . ~/.bash_aliases diff --git a/7.1/Dockerfile b/7.1/Dockerfile index e1d3dbcb..61843ead 100644 --- a/7.1/Dockerfile +++ b/7.1/Dockerfile @@ -48,9 +48,6 @@ RUN set -xe; \ curl -sSL https://packagecloud.io/github/git-lfs/gpgkey | apt-key add -; \ echo 'deb https://packagecloud.io/github/git-lfs/debian/ jessie main' | tee /etc/apt/sources.list.d/github_git-lfs.list; \ echo 'deb-src https://packagecloud.io/github/git-lfs/debian/ jessie main' | tee -a /etc/apt/sources.list.d/github_git-lfs.list; \ - # yarn repo - curl -sSL https://dl.yarnpkg.com/debian/pubkey.gpg | apt-key add -; \ - echo "deb https://dl.yarnpkg.com/debian/ stable main" | tee /etc/apt/sources.list.d/yarn.list; \ # MSQSQL repo - msodbcsql17, pecl/sqlsrv and pecl/pdo_sqlsrv (PHP 7.0+ only) curl -sSL https://packages.microsoft.com/keys/microsoft.asc | apt-key add -; \ echo 'deb https://packages.microsoft.com/debian/8/prod jessie main' | tee /etc/apt/sources.list.d/mssql.list; @@ -117,7 +114,7 @@ RUN set -xe; \ echo "export VISIBLE=now" >> /etc/profile ENV NOTVISIBLE "in users profile" -# Install PHP extentions +# PHP RUN set -xe; \ buildDeps=" \ g++ \ @@ -223,9 +220,6 @@ RUN set -xe; \ apt-get purge -y --auto-remove -o APT::AutoRemove::RecommendsImportant=false $buildDeps >/dev/null; \ apt-get clean; rm -rf /var/lib/apt/lists/* -# Copy mhsendmail binary from stage 1 -COPY --from=mhbuild /go/bin/mhsendmail /usr/local/bin/mhsendmail - ENV COMPOSER_VERSION=1.6.3 \ DRUSH_VERSION=8.1.16 \ DRUSH_LAUNCHER_VERSION=0.6.0 \ @@ -254,17 +248,30 @@ RUN set -xe; \ # Make all binaries executable in one shot chmod +x /usr/local/bin/* -# Other language packages and dependencies +# Node.js +ENV NODE_VERSION=8.x +RUN set -xe; \ + # Node.js repo + curl -sSL https://deb.nodesource.com/gpgkey/nodesource.gpg.key | apt-key add -; \ + echo "deb https://deb.nodesource.com/node_${NODE_VERSION} jessie main" | sudo tee /etc/apt/sources.list.d/nodesource.list; \ + echo "deb-src https://deb.nodesource.com/node_${NODE_VERSION} jessie main" | sudo tee -a /etc/apt/sources.list.d/nodesource.list; \ + # yarn repo + curl -sSL https://dl.yarnpkg.com/debian/pubkey.gpg | apt-key add -; \ + echo "deb https://dl.yarnpkg.com/debian/ stable main" | tee /etc/apt/sources.list.d/yarn.list; \ + apt-get update >/dev/null; apt-get -y --force-yes --no-install-recommends install >/dev/null \ + nodejs; \ + apt-get clean; rm -rf /var/lib/apt/lists/*; + +# Ruby RUN set -xe; \ apt-get update >/dev/null; apt-get -y --force-yes --no-install-recommends install >/dev/null \ ruby-full \ rlwrap; \ #build-essential; \ # Cleanup - apt-get clean; rm -rf /var/lib/apt/lists/* - -# bundler -RUN gem install bundler >/dev/null + apt-get clean; rm -rf /var/lib/apt/lists/*; \ + # bundler + gem install bundler >/dev/null # Home directory for bundle installs ENV BUNDLE_PATH .bundler @@ -272,23 +279,6 @@ ENV BUNDLE_PATH .bundler USER docker ENV HOME /home/docker -# Install nvm and a default node version -ENV NVM_VERSION=0.33.8 \ - NODE_VERSION=8.11.0 \ - NVM_DIR=$HOME/.nvm -# Don't use -x here - node/nvm stuff prints just too much stuff -RUN set -e; \ - curl -sSL https://raw.githubusercontent.com/creationix/nvm/v${NVM_VERSION}/install.sh | bash; \ - . $NVM_DIR/nvm.sh; \ - nvm install $NODE_VERSION >/dev/null; \ - nvm alias default $NODE_VERSION; \ - # Install global node packages - npm install -g npm >/dev/null; \ - # Cleanup - nvm clear-cache && npm cache clear --force; \ - # Fix npm complaining about permissions and not being able to update - sudo rm -rf $HOME/.config - # Install Composer based dependencies ENV PATH=$PATH:$HOME/.composer/vendor/bin \ DRUSH_LAUNCHER_FALLBACK=/usr/local/bin/drush8 @@ -316,6 +306,8 @@ RUN set -xe; \ USER root +# Copy mhsendmail binary from stage 1 +COPY --from=mhbuild /go/bin/mhsendmail /usr/local/bin/mhsendmail # Copy configs and scripts COPY --chown=docker:docker config/.acquia $HOME/.acquia COPY --chown=docker:docker config/.docksalrc $HOME/.docksalrc diff --git a/7.1/config/.docksalrc b/7.1/config/.docksalrc index 576167b7..40f7428b 100644 --- a/7.1/config/.docksalrc +++ b/7.1/config/.docksalrc @@ -3,10 +3,6 @@ # Allow alias expansion in non-interactive shells. shopt -s expand_aliases -# NVM initialization. -export NVM_DIR="/home/docker/.nvm" -[ -s "$NVM_DIR/nvm.sh" ] && . "$NVM_DIR/nvm.sh" # This loads nvm - # Source alias definitions. if [ -f ~/.bash_aliases ]; then . ~/.bash_aliases diff --git a/7.2/Dockerfile b/7.2/Dockerfile index 8f3968ed..9ceaeabe 100644 --- a/7.2/Dockerfile +++ b/7.2/Dockerfile @@ -48,9 +48,6 @@ RUN set -xe; \ curl -sSL https://packagecloud.io/github/git-lfs/gpgkey | apt-key add -; \ echo 'deb https://packagecloud.io/github/git-lfs/debian/ jessie main' | tee /etc/apt/sources.list.d/github_git-lfs.list; \ echo 'deb-src https://packagecloud.io/github/git-lfs/debian/ jessie main' | tee -a /etc/apt/sources.list.d/github_git-lfs.list; \ - # yarn repo - curl -sSL https://dl.yarnpkg.com/debian/pubkey.gpg | apt-key add -; \ - echo "deb https://dl.yarnpkg.com/debian/ stable main" | tee /etc/apt/sources.list.d/yarn.list; \ # MSQSQL repo - msodbcsql17, pecl/sqlsrv and pecl/pdo_sqlsrv (PHP 7.0+ only) curl -sSL https://packages.microsoft.com/keys/microsoft.asc | apt-key add -; \ echo 'deb https://packages.microsoft.com/debian/8/prod jessie main' | tee /etc/apt/sources.list.d/mssql.list; @@ -117,7 +114,7 @@ RUN set -xe; \ echo "export VISIBLE=now" >> /etc/profile ENV NOTVISIBLE "in users profile" -# Install PHP extentions +# PHP RUN set -xe; \ buildDeps=" \ g++ \ @@ -225,9 +222,6 @@ RUN set -xe; \ apt-get purge -y --auto-remove -o APT::AutoRemove::RecommendsImportant=false $buildDeps >/dev/null; \ apt-get clean; rm -rf /var/lib/apt/lists/* -# Copy mhsendmail binary from stage 1 -COPY --from=mhbuild /go/bin/mhsendmail /usr/local/bin/mhsendmail - ENV COMPOSER_VERSION=1.6.3 \ DRUSH_VERSION=8.1.16 \ DRUSH_LAUNCHER_VERSION=0.6.0 \ @@ -256,17 +250,30 @@ RUN set -xe; \ # Make all binaries executable in one shot chmod +x /usr/local/bin/* -# Other language packages and dependencies +# Node.js +ENV NODE_VERSION=8.x +RUN set -xe; \ + # Node.js repo + curl -sSL https://deb.nodesource.com/gpgkey/nodesource.gpg.key | apt-key add -; \ + echo "deb https://deb.nodesource.com/node_${NODE_VERSION} jessie main" | sudo tee /etc/apt/sources.list.d/nodesource.list; \ + echo "deb-src https://deb.nodesource.com/node_${NODE_VERSION} jessie main" | sudo tee -a /etc/apt/sources.list.d/nodesource.list; \ + # yarn repo + curl -sSL https://dl.yarnpkg.com/debian/pubkey.gpg | apt-key add -; \ + echo "deb https://dl.yarnpkg.com/debian/ stable main" | tee /etc/apt/sources.list.d/yarn.list; \ + apt-get update >/dev/null; apt-get -y --force-yes --no-install-recommends install >/dev/null \ + nodejs; \ + apt-get clean; rm -rf /var/lib/apt/lists/*; + +# Ruby RUN set -xe; \ apt-get update >/dev/null; apt-get -y --force-yes --no-install-recommends install >/dev/null \ ruby-full \ rlwrap; \ #build-essential; \ # Cleanup - apt-get clean; rm -rf /var/lib/apt/lists/* - -# bundler -RUN gem install bundler >/dev/null + apt-get clean; rm -rf /var/lib/apt/lists/*; \ + # bundler + gem install bundler >/dev/null # Home directory for bundle installs ENV BUNDLE_PATH .bundler @@ -274,23 +281,6 @@ ENV BUNDLE_PATH .bundler USER docker ENV HOME /home/docker -# Install nvm and a default node version -ENV NVM_VERSION=0.33.8 \ - NODE_VERSION=8.11.0 \ - NVM_DIR=$HOME/.nvm -# Don't use -x here - node/nvm stuff prints just too much stuff -RUN set -e; \ - curl -sSL https://raw.githubusercontent.com/creationix/nvm/v${NVM_VERSION}/install.sh | bash; \ - . $NVM_DIR/nvm.sh; \ - nvm install $NODE_VERSION >/dev/null; \ - nvm alias default $NODE_VERSION; \ - # Install global node packages - npm install -g npm >/dev/null; \ - # Cleanup - nvm clear-cache && npm cache clear --force; \ - # Fix npm complaining about permissions and not being able to update - sudo rm -rf $HOME/.config - # Install Composer based dependencies ENV PATH=$PATH:$HOME/.composer/vendor/bin \ DRUSH_LAUNCHER_FALLBACK=/usr/local/bin/drush8 @@ -318,6 +308,8 @@ RUN set -xe; \ USER root +# Copy mhsendmail binary from stage 1 +COPY --from=mhbuild /go/bin/mhsendmail /usr/local/bin/mhsendmail # Copy configs and scripts COPY --chown=docker:docker config/.acquia $HOME/.acquia COPY --chown=docker:docker config/.docksalrc $HOME/.docksalrc diff --git a/7.2/config/.docksalrc b/7.2/config/.docksalrc index 576167b7..40f7428b 100644 --- a/7.2/config/.docksalrc +++ b/7.2/config/.docksalrc @@ -3,10 +3,6 @@ # Allow alias expansion in non-interactive shells. shopt -s expand_aliases -# NVM initialization. -export NVM_DIR="/home/docker/.nvm" -[ -s "$NVM_DIR/nvm.sh" ] && . "$NVM_DIR/nvm.sh" # This loads nvm - # Source alias definitions. if [ -f ~/.bash_aliases ]; then . ~/.bash_aliases diff --git a/README.md b/README.md index 63ab47e7..e316264d 100644 --- a/README.md +++ b/README.md @@ -37,8 +37,7 @@ This image(s) is part of the [Docksal](http://docksal.io) image library. - gem - bundler - nodejs - - nvm - - nodejs (via nvm) + - nodejs - npm, yarn - python From 62dad43203c64eaee5ced5d5fe0c05fd68011493 Mon Sep 17 00:00:00 2001 From: Leonid Makarov Date: Thu, 31 May 2018 16:33:12 -0700 Subject: [PATCH 02/45] Using and extending the default supervisord configuration - Starting supervisord using /etc/supervisor/supervisord.conf config, which includes /etc/supervisor/conf.d/*.conf - Removed non-essential settings from the custom supervisor.conf - pretty much all of them are covered in /etc/supervisor/supervisord.conf (in Debian Stretch) --- 5.6/config/supervisord.conf | 20 -------------------- 5.6/startup.sh | 2 +- 7.0/config/supervisord.conf | 20 -------------------- 7.0/startup.sh | 2 +- 7.1/config/supervisord.conf | 20 -------------------- 7.1/startup.sh | 2 +- 7.2/config/supervisord.conf | 20 -------------------- 7.2/startup.sh | 2 +- 8 files changed, 4 insertions(+), 84 deletions(-) diff --git a/5.6/config/supervisord.conf b/5.6/config/supervisord.conf index 32b078b2..1ae1f475 100644 --- a/5.6/config/supervisord.conf +++ b/5.6/config/supervisord.conf @@ -1,26 +1,6 @@ [supervisord] nodaemon = true loglevel = debug -# ---------------------------------------------------------------------------------------------------- -# Optional stuff to make supervisord complain less about misc things not being configured -logfile = /var/log/supervisor/supervisord.log -pidfile = /var/run/supervisord.pid - -[unix_http_server] -file = /var/run/supervisord.sock -chmod = 0700 -username = dummy -password = dummy - -[supervisorctl] -serverurl = unix:///var/run/supervisord.sock -username = dummy -password = dummy - -[rpcinterface:supervisor] -supervisor.rpcinterface_factory = supervisor.rpcinterface:make_main_rpcinterface -# END: Optional stuff to make supervisord complain less about misc things not being configured -# ---------------------------------------------------------------------------------------------------- [program:php-fpm] command = /usr/local/sbin/php-fpm diff --git a/5.6/startup.sh b/5.6/startup.sh index 9a577e6b..1a5ca697 100755 --- a/5.6/startup.sh +++ b/5.6/startup.sh @@ -81,7 +81,7 @@ touch /var/run/cli echo-debug "Executing the requested command..." # Service mode (run as root) if [[ "$1" == "supervisord" ]]; then - exec gosu root supervisord -c /etc/supervisor/conf.d/supervisord.conf + exec gosu root supervisord -c /etc/supervisor/supervisord.conf # Command mode (run as docker user) else # This makes sure the environment is set up correctly for the docker user diff --git a/7.0/config/supervisord.conf b/7.0/config/supervisord.conf index 32b078b2..1ae1f475 100644 --- a/7.0/config/supervisord.conf +++ b/7.0/config/supervisord.conf @@ -1,26 +1,6 @@ [supervisord] nodaemon = true loglevel = debug -# ---------------------------------------------------------------------------------------------------- -# Optional stuff to make supervisord complain less about misc things not being configured -logfile = /var/log/supervisor/supervisord.log -pidfile = /var/run/supervisord.pid - -[unix_http_server] -file = /var/run/supervisord.sock -chmod = 0700 -username = dummy -password = dummy - -[supervisorctl] -serverurl = unix:///var/run/supervisord.sock -username = dummy -password = dummy - -[rpcinterface:supervisor] -supervisor.rpcinterface_factory = supervisor.rpcinterface:make_main_rpcinterface -# END: Optional stuff to make supervisord complain less about misc things not being configured -# ---------------------------------------------------------------------------------------------------- [program:php-fpm] command = /usr/local/sbin/php-fpm diff --git a/7.0/startup.sh b/7.0/startup.sh index 9a577e6b..1a5ca697 100755 --- a/7.0/startup.sh +++ b/7.0/startup.sh @@ -81,7 +81,7 @@ touch /var/run/cli echo-debug "Executing the requested command..." # Service mode (run as root) if [[ "$1" == "supervisord" ]]; then - exec gosu root supervisord -c /etc/supervisor/conf.d/supervisord.conf + exec gosu root supervisord -c /etc/supervisor/supervisord.conf # Command mode (run as docker user) else # This makes sure the environment is set up correctly for the docker user diff --git a/7.1/config/supervisord.conf b/7.1/config/supervisord.conf index 32b078b2..1ae1f475 100644 --- a/7.1/config/supervisord.conf +++ b/7.1/config/supervisord.conf @@ -1,26 +1,6 @@ [supervisord] nodaemon = true loglevel = debug -# ---------------------------------------------------------------------------------------------------- -# Optional stuff to make supervisord complain less about misc things not being configured -logfile = /var/log/supervisor/supervisord.log -pidfile = /var/run/supervisord.pid - -[unix_http_server] -file = /var/run/supervisord.sock -chmod = 0700 -username = dummy -password = dummy - -[supervisorctl] -serverurl = unix:///var/run/supervisord.sock -username = dummy -password = dummy - -[rpcinterface:supervisor] -supervisor.rpcinterface_factory = supervisor.rpcinterface:make_main_rpcinterface -# END: Optional stuff to make supervisord complain less about misc things not being configured -# ---------------------------------------------------------------------------------------------------- [program:php-fpm] command = /usr/local/sbin/php-fpm diff --git a/7.1/startup.sh b/7.1/startup.sh index 9a577e6b..1a5ca697 100755 --- a/7.1/startup.sh +++ b/7.1/startup.sh @@ -81,7 +81,7 @@ touch /var/run/cli echo-debug "Executing the requested command..." # Service mode (run as root) if [[ "$1" == "supervisord" ]]; then - exec gosu root supervisord -c /etc/supervisor/conf.d/supervisord.conf + exec gosu root supervisord -c /etc/supervisor/supervisord.conf # Command mode (run as docker user) else # This makes sure the environment is set up correctly for the docker user diff --git a/7.2/config/supervisord.conf b/7.2/config/supervisord.conf index 32b078b2..1ae1f475 100644 --- a/7.2/config/supervisord.conf +++ b/7.2/config/supervisord.conf @@ -1,26 +1,6 @@ [supervisord] nodaemon = true loglevel = debug -# ---------------------------------------------------------------------------------------------------- -# Optional stuff to make supervisord complain less about misc things not being configured -logfile = /var/log/supervisor/supervisord.log -pidfile = /var/run/supervisord.pid - -[unix_http_server] -file = /var/run/supervisord.sock -chmod = 0700 -username = dummy -password = dummy - -[supervisorctl] -serverurl = unix:///var/run/supervisord.sock -username = dummy -password = dummy - -[rpcinterface:supervisor] -supervisor.rpcinterface_factory = supervisor.rpcinterface:make_main_rpcinterface -# END: Optional stuff to make supervisord complain less about misc things not being configured -# ---------------------------------------------------------------------------------------------------- [program:php-fpm] command = /usr/local/sbin/php-fpm diff --git a/7.2/startup.sh b/7.2/startup.sh index 9a577e6b..1a5ca697 100755 --- a/7.2/startup.sh +++ b/7.2/startup.sh @@ -81,7 +81,7 @@ touch /var/run/cli echo-debug "Executing the requested command..." # Service mode (run as root) if [[ "$1" == "supervisord" ]]; then - exec gosu root supervisord -c /etc/supervisor/conf.d/supervisord.conf + exec gosu root supervisord -c /etc/supervisor/supervisord.conf # Command mode (run as docker user) else # This makes sure the environment is set up correctly for the docker user From 5117baaf51fd0b93cb0fb5d3774cda816b9761c0 Mon Sep 17 00:00:00 2001 From: Leonid Makarov Date: Thu, 31 May 2018 19:05:59 -0700 Subject: [PATCH 03/45] Build refactoring --- .travis.yml | 44 +++++++++++++++++++++++--------------------- 5.6/Makefile | 21 ++++++++++----------- 7.0/Makefile | 21 ++++++++++----------- 7.1/Makefile | 21 ++++++++++----------- 7.2/Makefile | 21 ++++++++++----------- tests/test.bats | 2 +- 6 files changed, 64 insertions(+), 66 deletions(-) diff --git a/.travis.yml b/.travis.yml index 8d7d8198..90d7af32 100644 --- a/.travis.yml +++ b/.travis.yml @@ -23,30 +23,32 @@ install: - fin sysinfo script: - - cd ${VERSION} + # Build the base image + - cd ${TRAVIS_BUILD_DIR}/${VERSION} - travis_retry make && make test # Retry builds, as pecl.php.net tends to time out often -after_success: | - docker image ls - - if [[ "${TRAVIS_PULL_REQUEST}" == "false" ]]; then - [[ "${TRAVIS_BRANCH}" == "develop" ]] && TAG="edge-php${VERSION}" - [[ "${TRAVIS_BRANCH}" == "master" ]] && TAG="php${VERSION}" - [[ "${TRAVIS_TAG}" != "" ]] && TAG="${TRAVIS_TAG:1:3}-php${VERSION}" - - if [[ "$TAG" != "" ]]; then - docker login -u "${DOCKER_USER}" -p "${DOCKER_PASS}" - # Push edge, stable and release tags - docker tag ${REPO}:${VERSION} ${REPO}:${TAG} - docker push ${REPO}:${TAG} - - # Push "latest" tag - if [[ "${TRAVIS_BRANCH}" == "master" ]] && [[ "${VERSION}" == "${LATEST_VERSION}" ]]; then - docker tag ${REPO}:${VERSION} ${REPO}:latest - docker push ${REPO}:latest +after_success: + - docker image ls + - | + if [[ "${TRAVIS_PULL_REQUEST}" == "false" ]]; then + [[ "${TRAVIS_BRANCH}" == "develop" ]] && TAG="edge-php${VERSION}" + [[ "${TRAVIS_BRANCH}" == "master" ]] && TAG="php${VERSION}" + [[ "${TRAVIS_TAG}" != "" ]] && TAG="${TRAVIS_TAG:1:3}-php${VERSION}" + + if [[ "$TAG" != "" ]]; then + docker login -u "${DOCKER_USER}" -p "${DOCKER_PASS}" + # Push edge, stable and release tags + # Base image + docker tag ${REPO}:build-${VERSION} ${REPO}:${TAG} + docker push ${REPO}:${TAG} + + # Push "latest" tag + if [[ "${TRAVIS_BRANCH}" == "master" ]] && [[ "${VERSION}" == "${LATEST_VERSION}" ]]; then + docker tag ${REPO}:build-${VERSION} ${REPO}:latest + docker push ${REPO}:latest + fi fi fi - fi after_failure: - - make logs + - cd ${TRAVIS_BUILD_DIR}/${VERSION} && make logs diff --git a/5.6/Makefile b/5.6/Makefile index b7e6d79d..24c7e6f9 100644 --- a/5.6/Makefile +++ b/5.6/Makefile @@ -1,10 +1,9 @@ -include env_make -PHP_VERSION = 5.6 -VERSION ?= php-fpm-$(PHP_VERSION) - +VERSION ?= 5.6 REPO = docksal/cli -NAME = docksal-cli-$(PHP_VERSION) +TAG = build-$(VERSION) +NAME = docksal-cli-$(VERSION) # Improve write performance for /home/docker by turning it into a volume VOLUMES += -v /home/docker @@ -12,22 +11,22 @@ VOLUMES += -v /home/docker .PHONY: build test push shell run start stop logs clean release build: - docker build -t $(REPO):$(VERSION) . + docker build -t $(REPO):$(TAG) . test: - IMAGE=$(REPO):$(VERSION) NAME=$(NAME) PHP_VERSION=$(PHP_VERSION) ../tests/test.bats + IMAGE=$(REPO):$(TAG) NAME=$(NAME) VERSION=$(VERSION) ../tests/test.bats push: - docker push $(REPO):$(VERSION) + docker push $(REPO):$(TAG) shell: - docker run --rm --name $(NAME) -it $(PORTS) $(VOLUMES) $(ENV) $(REPO):$(VERSION) /bin/bash + docker run --rm --name $(NAME) -it $(PORTS) $(VOLUMES) $(ENV) $(REPO):$(TAG) /bin/bash run: - docker run --rm --name $(NAME) -it $(PORTS) $(VOLUMES) $(ENV) $(REPO):$(VERSION) + docker run --rm --name $(NAME) -it $(PORTS) $(VOLUMES) $(ENV) $(REPO):$(TAG) start: - docker run -d --name $(NAME) $(PORTS) $(VOLUMES) $(ENV) $(REPO):$(VERSION) + docker run -d --name $(NAME) $(PORTS) $(VOLUMES) $(ENV) $(REPO):$(TAG) exec: docker exec -it $(NAME) /bin/bash @@ -42,6 +41,6 @@ clean: docker rm -f $(NAME) release: build - make push -e VERSION=$(VERSION) + make push -e TAG=$(TAG) default: build diff --git a/7.0/Makefile b/7.0/Makefile index 0f075d49..683dca13 100644 --- a/7.0/Makefile +++ b/7.0/Makefile @@ -1,10 +1,9 @@ -include env_make -PHP_VERSION = 7.0 -VERSION ?= php-fpm-$(PHP_VERSION) - +VERSION ?= 7.0 REPO = docksal/cli -NAME = docksal-cli-$(PHP_VERSION) +TAG = build-$(VERSION) +NAME = docksal-cli-$(VERSION) # Improve write performance for /home/docker by turning it into a volume VOLUMES += -v /home/docker @@ -12,22 +11,22 @@ VOLUMES += -v /home/docker .PHONY: build test push shell run start stop logs clean release build: - docker build -t $(REPO):$(VERSION) . + docker build -t $(REPO):$(TAG) . test: - IMAGE=$(REPO):$(VERSION) NAME=$(NAME) PHP_VERSION=$(PHP_VERSION) ../tests/test.bats + IMAGE=$(REPO):$(TAG) NAME=$(NAME) VERSION=$(VERSION) ../tests/test.bats push: - docker push $(REPO):$(VERSION) + docker push $(REPO):$(TAG) shell: - docker run --rm --name $(NAME) -it $(PORTS) $(VOLUMES) $(ENV) $(REPO):$(VERSION) /bin/bash + docker run --rm --name $(NAME) -it $(PORTS) $(VOLUMES) $(ENV) $(REPO):$(TAG) /bin/bash run: - docker run --rm --name $(NAME) -it $(PORTS) $(VOLUMES) $(ENV) $(REPO):$(VERSION) + docker run --rm --name $(NAME) -it $(PORTS) $(VOLUMES) $(ENV) $(REPO):$(TAG) start: - docker run -d --name $(NAME) $(PORTS) $(VOLUMES) $(ENV) $(REPO):$(VERSION) + docker run -d --name $(NAME) $(PORTS) $(VOLUMES) $(ENV) $(REPO):$(TAG) exec: docker exec -it $(NAME) /bin/bash @@ -42,6 +41,6 @@ clean: docker rm -f $(NAME) release: build - make push -e VERSION=$(VERSION) + make push -e TAG=$(TAG) default: build diff --git a/7.1/Makefile b/7.1/Makefile index 0952ff90..9a906417 100644 --- a/7.1/Makefile +++ b/7.1/Makefile @@ -1,10 +1,9 @@ -include env_make -PHP_VERSION = 7.1 -VERSION ?= php-fpm-$(PHP_VERSION) - +VERSION ?= 7.1 REPO = docksal/cli -NAME = docksal-cli-$(PHP_VERSION) +TAG = build-$(VERSION) +NAME = docksal-cli-$(VERSION) # Improve write performance for /home/docker by turning it into a volume VOLUMES += -v /home/docker @@ -12,22 +11,22 @@ VOLUMES += -v /home/docker .PHONY: build test push shell run start stop logs clean release build: - docker build -t $(REPO):$(VERSION) . + docker build -t $(REPO):$(TAG) . test: - IMAGE=$(REPO):$(VERSION) NAME=$(NAME) PHP_VERSION=$(PHP_VERSION) ../tests/test.bats + IMAGE=$(REPO):$(TAG) NAME=$(NAME) VERSION=$(VERSION) ../tests/test.bats push: - docker push $(REPO):$(VERSION) + docker push $(REPO):$(TAG) shell: - docker run --rm --name $(NAME) -it $(PORTS) $(VOLUMES) $(ENV) $(REPO):$(VERSION) /bin/bash + docker run --rm --name $(NAME) -it $(PORTS) $(VOLUMES) $(ENV) $(REPO):$(TAG) /bin/bash run: - docker run --rm --name $(NAME) -it $(PORTS) $(VOLUMES) $(ENV) $(REPO):$(VERSION) + docker run --rm --name $(NAME) -it $(PORTS) $(VOLUMES) $(ENV) $(REPO):$(TAG) start: - docker run -d --name $(NAME) $(PORTS) $(VOLUMES) $(ENV) $(REPO):$(VERSION) + docker run -d --name $(NAME) $(PORTS) $(VOLUMES) $(ENV) $(REPO):$(TAG) exec: docker exec -it $(NAME) /bin/bash @@ -42,6 +41,6 @@ clean: docker rm -f $(NAME) release: build - make push -e VERSION=$(VERSION) + make push -e TAG=$(TAG) default: build diff --git a/7.2/Makefile b/7.2/Makefile index 0720ee93..538c0eb9 100644 --- a/7.2/Makefile +++ b/7.2/Makefile @@ -1,10 +1,9 @@ -include env_make -PHP_VERSION = 7.2 -VERSION ?= php-fpm-$(PHP_VERSION) - +VERSION ?= 7.2 REPO = docksal/cli -NAME = docksal-cli-$(PHP_VERSION) +TAG = build-$(VERSION) +NAME = docksal-cli-$(VERSION) # Improve write performance for /home/docker by turning it into a volume VOLUMES += -v /home/docker @@ -12,22 +11,22 @@ VOLUMES += -v /home/docker .PHONY: build test push shell run start stop logs clean release build: - docker build -t $(REPO):$(VERSION) . + docker build -t $(REPO):$(TAG) . test: - IMAGE=$(REPO):$(VERSION) NAME=$(NAME) PHP_VERSION=$(PHP_VERSION) ../tests/test.bats + IMAGE=$(REPO):$(TAG) NAME=$(NAME) VERSION=$(VERSION) ../tests/test.bats push: - docker push $(REPO):$(VERSION) + docker push $(REPO):$(TAG) shell: - docker run --rm --name $(NAME) -it $(PORTS) $(VOLUMES) $(ENV) $(REPO):$(VERSION) /bin/bash + docker run --rm --name $(NAME) -it $(PORTS) $(VOLUMES) $(ENV) $(REPO):$(TAG) /bin/bash run: - docker run --rm --name $(NAME) -it $(PORTS) $(VOLUMES) $(ENV) $(REPO):$(VERSION) + docker run --rm --name $(NAME) -it $(PORTS) $(VOLUMES) $(ENV) $(REPO):$(TAG) start: - docker run -d --name $(NAME) $(PORTS) $(VOLUMES) $(ENV) $(REPO):$(VERSION) + docker run -d --name $(NAME) $(PORTS) $(VOLUMES) $(ENV) $(REPO):$(TAG) exec: docker exec -it $(NAME) /bin/bash @@ -42,6 +41,6 @@ clean: docker rm -f $(NAME) release: build - make push -e VERSION=$(VERSION) + make push -e TAG=$(TAG) default: build diff --git a/tests/test.bats b/tests/test.bats index e53c6b25..db5910f8 100755 --- a/tests/test.bats +++ b/tests/test.bats @@ -101,7 +101,7 @@ _healthcheck_wait () phpInfo=$(docker exec -u docker "$NAME" php -i) output=$(echo "$phpInfo" | grep "PHP Version") - echo "$output" | grep "${PHP_VERSION}" + echo "$output" | grep "${VERSION}" unset output output=$(echo "$phpInfo" | grep "memory_limit") From 1e65a1b0d4b79574ae799b4e9784895d56ee3b1f Mon Sep 17 00:00:00 2001 From: Leonid Makarov Date: Thu, 31 May 2018 19:06:48 -0700 Subject: [PATCH 04/45] Cloud9 IDE integration --- cloud9/Dockerfile | 16 ++++++++++++++++ cloud9/config/supervisord-cloud9.conf | 7 +++++++ 2 files changed, 23 insertions(+) create mode 100644 cloud9/Dockerfile create mode 100644 cloud9/config/supervisord-cloud9.conf diff --git a/cloud9/Dockerfile b/cloud9/Dockerfile new file mode 100644 index 00000000..bf900540 --- /dev/null +++ b/cloud9/Dockerfile @@ -0,0 +1,16 @@ +ARG FROM_TAG + +FROM docksal/cli:${FROM_TAG} + +# Cloud9 IDE and dependencies +RUN set -x; \ + apt-get update; \ + apt-get install -y tmux g++ make; \ + git clone https://github.com/c9/core.git /opt/c9sdk; \ + curl -s -L https://raw.githubusercontent.com/c9/install/master/link.sh | bash; \ + /opt/c9sdk/scripts/install-sdk.sh; \ + rm -rf /opt/c9sdk/.git; \ + chown -R docker:docker /opt/c9sdk; + +# Launch Cloud9 via supervisord +COPY config/supervisord-cloud9.conf /etc/supervisor/conf.d/cloud9.conf diff --git a/cloud9/config/supervisord-cloud9.conf b/cloud9/config/supervisord-cloud9.conf new file mode 100644 index 00000000..bf09b4bc --- /dev/null +++ b/cloud9/config/supervisord-cloud9.conf @@ -0,0 +1,7 @@ +# Cloud9 IDE +[program:c9] +command = gosu docker node /opt/c9sdk/server.js -l 0.0.0.0 -p 3000 -w /var/www -a : +stdout_logfile = /dev/stdout +stdout_logfile_maxbytes = 0 +stderr_logfile = /dev/stderr +stderr_logfile_maxbytes = 0 From c28092d5b1b7709763e70a263173c671b189af5b Mon Sep 17 00:00:00 2001 From: Leonid Makarov Date: Thu, 31 May 2018 19:07:38 -0700 Subject: [PATCH 05/45] Cloud9 build and tests --- .travis.yml | 7 ++++ cloud9/Makefile | 47 ++++++++++++++++++++++ cloud9/tests/test.bats | 89 ++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 143 insertions(+) create mode 100644 cloud9/Makefile create mode 100755 cloud9/tests/test.bats diff --git a/.travis.yml b/.travis.yml index 90d7af32..ee8d56cf 100644 --- a/.travis.yml +++ b/.travis.yml @@ -26,6 +26,9 @@ script: # Build the base image - cd ${TRAVIS_BUILD_DIR}/${VERSION} - travis_retry make && make test # Retry builds, as pecl.php.net tends to time out often + # Build the Cloud9 flavor + - cd ${TRAVIS_BUILD_DIR}/cloud9 + - travis_retry make && make test after_success: - docker image ls @@ -41,6 +44,9 @@ after_success: # Base image docker tag ${REPO}:build-${VERSION} ${REPO}:${TAG} docker push ${REPO}:${TAG} + # Cloud9 flavor + docker tag ${REPO}:build-${VERSION}-ide ${REPO}:${TAG}-ide + docker push ${REPO}:${TAG}-ide # Push "latest" tag if [[ "${TRAVIS_BRANCH}" == "master" ]] && [[ "${VERSION}" == "${LATEST_VERSION}" ]]; then @@ -52,3 +58,4 @@ after_success: after_failure: - cd ${TRAVIS_BUILD_DIR}/${VERSION} && make logs + - cd ${TRAVIS_BUILD_DIR}/cloud9 && make logs diff --git a/cloud9/Makefile b/cloud9/Makefile new file mode 100644 index 00000000..2fe4c23c --- /dev/null +++ b/cloud9/Makefile @@ -0,0 +1,47 @@ +-include env_make + +VERSION ?= 7.1 +REPO = docksal/cli +FROM_TAG = build-$(VERSION) +TAG = $(FROM_TAG)-ide +NAME = docksal-cli-$(VERSION)-ide + +# Improve write performance for /home/docker by turning it into a volume +VOLUMES += -v /home/docker + +.PHONY: build test push shell run start stop logs clean release + +build: + docker build --build-arg FROM_TAG=$(FROM_TAG) -t $(REPO):$(TAG) . + +test: + IMAGE=$(REPO):$(TAG) NAME=$(NAME) tests/test.bats + +push: + docker push $(REPO):$(TAG) + +shell: + docker run --rm --name $(NAME) -it $(PORTS) $(VOLUMES) $(ENV) $(REPO):$(TAG) /bin/bash + +run: + docker run --rm --name $(NAME) -it $(PORTS) $(VOLUMES) $(ENV) $(REPO):$(TAG) + +start: + docker run -d --name $(NAME) $(PORTS) $(VOLUMES) $(ENV) $(REPO):$(TAG) + +exec: + docker exec -it $(NAME) /bin/bash + +stop: + docker stop $(NAME) + +logs: + docker logs $(NAME) + +clean: + docker rm -f $(NAME) + +release: build + make push -e TAG=$(TAG) + +default: build diff --git a/cloud9/tests/test.bats b/cloud9/tests/test.bats new file mode 100755 index 00000000..2e00e2b2 --- /dev/null +++ b/cloud9/tests/test.bats @@ -0,0 +1,89 @@ +#!/usr/bin/env bats + +# Debugging +teardown() { + echo + # TODO: figure out how to deal with this (output from previous run commands showing up along with the error message) + echo "Note: ignore the lines between \"...failed\" above and here" + echo + echo "Status: ${status}" + echo "Output:" + echo "================================================================" + echo "${output}" + echo "================================================================" +} + +# Checks container health status (if available) +# Relies on healchecks introduced in docksal/cli v1.3.0+, uses `sleep` as a fallback +# @param $1 container id/name +_healthcheck () +{ + local health_status + health_status=$(docker inspect --format='{{json .State.Health.Status}}' "$1" 2>/dev/null) + + # Wait for 5s then exit with 0 if a container does not have a health status property + # Necessary for backward compatibility with images that do not support health checks + if [[ $? != 0 ]]; then + echo "Waiting 10s for container to start..." + sleep 10 + return 0 + fi + + # If it does, check the status + echo $health_status | grep '"healthy"' >/dev/null 2>&1 +} + +# Waits for containers to become healthy +# For reasoning why we are not using `depends_on` `condition` see here: +# https://github.com/docksal/docksal/issues/225#issuecomment-306604063 +# TODO: make this universal. Currently hardcoded for cli only. +_healthcheck_wait () +{ + # Wait for cli to become ready by watching its health status + local container_name="${NAME}" + local delay=5 + local timeout=30 + local elapsed=0 + + until _healthcheck "$container_name"; do + echo "Waiting for $container_name to become ready..." + sleep "$delay"; + + # Give the container 30s to become ready + elapsed=$((elapsed + delay)) + if ((elapsed > timeout)); then + echo-error "$container_name heathcheck failed" \ + "Container did not enter a healthy state within the expected amount of time." \ + "Try ${yellow}fin restart${NC}" + exit 1 + fi + done + + return 0 +} + + +# Global skip +# Uncomment below, then comment skip in the test you want to debug. When done, reverse. +#SKIP=1 + +@test "Cloud 9 IDE" { + [[ $SKIP == 1 ]] && skip + + ### Setup ### + docker rm -vf "$NAME" >/dev/null 2>&1 || true + docker run --name "$NAME" -d \ + -v /home/docker \ + -v $(pwd)/../tests/docroot:/var/www/docroot \ + "$IMAGE" + _healthcheck_wait + + ### Tests ### + + run docker logs "$NAME" + echo "$output" | grep "Cloud9 is up and running" + unset output + + ### Cleanup ### + docker rm -vf "$NAME" >/dev/null 2>&1 || true +} From f13ececa98865d17ef701ed16971fe430dab5d18 Mon Sep 17 00:00:00 2001 From: Leonid Makarov Date: Thu, 31 May 2018 21:27:05 -0700 Subject: [PATCH 06/45] Fix missing yarn --- 5.6/Dockerfile | 9 +++++---- 7.0/Dockerfile | 9 +++++---- 7.1/Dockerfile | 9 +++++---- 7.2/Dockerfile | 9 +++++---- 4 files changed, 20 insertions(+), 16 deletions(-) diff --git a/5.6/Dockerfile b/5.6/Dockerfile index 8026ccbb..6b750c7c 100644 --- a/5.6/Dockerfile +++ b/5.6/Dockerfile @@ -79,7 +79,6 @@ RUN set -xe; \ unzip \ zip \ zsh \ - yarn \ ;\ # More recent version of git to get composer's git cache. apt-get -y --force-yes --no-install-recommends -t jessie-backports install git >/dev/null ;\ @@ -253,15 +252,17 @@ RUN set -xe; \ curl -sSL https://dl.yarnpkg.com/debian/pubkey.gpg | apt-key add -; \ echo "deb https://dl.yarnpkg.com/debian/ stable main" | tee /etc/apt/sources.list.d/yarn.list; \ apt-get update >/dev/null; apt-get -y --force-yes --no-install-recommends install >/dev/null \ - nodejs; \ + nodejs \ + yarn \ + ;\ apt-get clean; rm -rf /var/lib/apt/lists/*; # Ruby RUN set -xe; \ apt-get update >/dev/null; apt-get -y --force-yes --no-install-recommends install >/dev/null \ ruby-full \ - rlwrap; \ - #build-essential; \ + rlwrap \ + ;\ # Cleanup apt-get clean; rm -rf /var/lib/apt/lists/*; \ # bundler diff --git a/7.0/Dockerfile b/7.0/Dockerfile index 123c912c..54b14e0d 100644 --- a/7.0/Dockerfile +++ b/7.0/Dockerfile @@ -82,7 +82,6 @@ RUN set -xe; \ unzip \ zip \ zsh \ - yarn \ ;\ # More recent version of git to get composer's git cache. apt-get -y --force-yes --no-install-recommends -t jessie-backports install git >/dev/null ;\ @@ -259,15 +258,17 @@ RUN set -xe; \ curl -sSL https://dl.yarnpkg.com/debian/pubkey.gpg | apt-key add -; \ echo "deb https://dl.yarnpkg.com/debian/ stable main" | tee /etc/apt/sources.list.d/yarn.list; \ apt-get update >/dev/null; apt-get -y --force-yes --no-install-recommends install >/dev/null \ - nodejs; \ + nodejs \ + yarn \ + ;\ apt-get clean; rm -rf /var/lib/apt/lists/*; # Ruby RUN set -xe; \ apt-get update >/dev/null; apt-get -y --force-yes --no-install-recommends install >/dev/null \ ruby-full \ - rlwrap; \ - #build-essential; \ + rlwrap \ + ;\ # Cleanup apt-get clean; rm -rf /var/lib/apt/lists/*; \ # bundler diff --git a/7.1/Dockerfile b/7.1/Dockerfile index 61843ead..8ae8dbf9 100644 --- a/7.1/Dockerfile +++ b/7.1/Dockerfile @@ -82,7 +82,6 @@ RUN set -xe; \ unzip \ zip \ zsh \ - yarn \ ;\ # More recent version of git to get composer's git cache. apt-get -y --force-yes --no-install-recommends -t jessie-backports install git >/dev/null ;\ @@ -259,15 +258,17 @@ RUN set -xe; \ curl -sSL https://dl.yarnpkg.com/debian/pubkey.gpg | apt-key add -; \ echo "deb https://dl.yarnpkg.com/debian/ stable main" | tee /etc/apt/sources.list.d/yarn.list; \ apt-get update >/dev/null; apt-get -y --force-yes --no-install-recommends install >/dev/null \ - nodejs; \ + nodejs \ + yarn \ + ;\ apt-get clean; rm -rf /var/lib/apt/lists/*; # Ruby RUN set -xe; \ apt-get update >/dev/null; apt-get -y --force-yes --no-install-recommends install >/dev/null \ ruby-full \ - rlwrap; \ - #build-essential; \ + rlwrap \ + ;\ # Cleanup apt-get clean; rm -rf /var/lib/apt/lists/*; \ # bundler diff --git a/7.2/Dockerfile b/7.2/Dockerfile index 9ceaeabe..448f68a6 100644 --- a/7.2/Dockerfile +++ b/7.2/Dockerfile @@ -82,7 +82,6 @@ RUN set -xe; \ unzip \ zip \ zsh \ - yarn \ ;\ # More recent version of git to get composer's git cache. apt-get -y --force-yes --no-install-recommends -t jessie-backports install git >/dev/null ;\ @@ -261,15 +260,17 @@ RUN set -xe; \ curl -sSL https://dl.yarnpkg.com/debian/pubkey.gpg | apt-key add -; \ echo "deb https://dl.yarnpkg.com/debian/ stable main" | tee /etc/apt/sources.list.d/yarn.list; \ apt-get update >/dev/null; apt-get -y --force-yes --no-install-recommends install >/dev/null \ - nodejs; \ + nodejs \ + yarn \ + ;\ apt-get clean; rm -rf /var/lib/apt/lists/*; # Ruby RUN set -xe; \ apt-get update >/dev/null; apt-get -y --force-yes --no-install-recommends install >/dev/null \ ruby-full \ - rlwrap; \ - #build-essential; \ + rlwrap \ + ;\ # Cleanup apt-get clean; rm -rf /var/lib/apt/lists/*; \ # bundler From 87047b4c05ee37a2d035b6916b0902ce62249bf5 Mon Sep 17 00:00:00 2001 From: Leonid Makarov Date: Thu, 31 May 2018 21:32:43 -0700 Subject: [PATCH 07/45] Optimize chmod usage Reduces a layer size by 26MB --- 5.6/Dockerfile | 2 +- 7.0/Dockerfile | 2 +- 7.1/Dockerfile | 2 +- 7.2/Dockerfile | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/5.6/Dockerfile b/5.6/Dockerfile index 2a6d61d7..cd6cb14f 100644 --- a/5.6/Dockerfile +++ b/5.6/Dockerfile @@ -243,7 +243,7 @@ RUN set -xe; \ # gomplate curl -sSL https://github.com/hairyhenderson/gomplate/releases/download/v${GOMPLATE_VERSION}/gomplate_linux-amd64-slim -o /usr/local/bin/gomplate; \ # Make all binaries executable in one shot - chmod +x /usr/local/bin/* + cd /usr/local/bin && chmod +x composer drush8 drush drupal wp mg2-codegen blackfire gomplate; # Other language packages and dependencies RUN set -xe; \ diff --git a/7.0/Dockerfile b/7.0/Dockerfile index ae314a24..04319a45 100644 --- a/7.0/Dockerfile +++ b/7.0/Dockerfile @@ -252,7 +252,7 @@ RUN set -xe; \ # gomplate curl -sSL https://github.com/hairyhenderson/gomplate/releases/download/v${GOMPLATE_VERSION}/gomplate_linux-amd64-slim -o /usr/local/bin/gomplate; \ # Make all binaries executable in one shot - chmod +x /usr/local/bin/* + cd /usr/local/bin && chmod +x composer drush8 drush drupal wp mg2-codegen blackfire gomplate; # Other language packages and dependencies RUN set -xe; \ diff --git a/7.1/Dockerfile b/7.1/Dockerfile index e1d3dbcb..c381db24 100644 --- a/7.1/Dockerfile +++ b/7.1/Dockerfile @@ -252,7 +252,7 @@ RUN set -xe; \ # gomplate curl -sSL https://github.com/hairyhenderson/gomplate/releases/download/v${GOMPLATE_VERSION}/gomplate_linux-amd64-slim -o /usr/local/bin/gomplate; \ # Make all binaries executable in one shot - chmod +x /usr/local/bin/* + cd /usr/local/bin && chmod +x composer drush8 drush drupal wp mg2-codegen blackfire gomplate; # Other language packages and dependencies RUN set -xe; \ diff --git a/7.2/Dockerfile b/7.2/Dockerfile index 8f3968ed..f94d2936 100644 --- a/7.2/Dockerfile +++ b/7.2/Dockerfile @@ -254,7 +254,7 @@ RUN set -xe; \ # gomplate curl -sSL https://github.com/hairyhenderson/gomplate/releases/download/v${GOMPLATE_VERSION}/gomplate_linux-amd64-slim -o /usr/local/bin/gomplate; \ # Make all binaries executable in one shot - chmod +x /usr/local/bin/* + cd /usr/local/bin && chmod +x composer drush8 drush drupal wp mg2-codegen blackfire gomplate; # Other language packages and dependencies RUN set -xe; \ From 7afcb2b7efc09eba49303c0f47de91ba61c3089f Mon Sep 17 00:00:00 2001 From: Leonid Makarov Date: Thu, 31 May 2018 21:33:58 -0700 Subject: [PATCH 08/45] Removed duplicate COPY statement in 5.6 [ci skip] --- 5.6/Dockerfile | 3 --- 1 file changed, 3 deletions(-) diff --git a/5.6/Dockerfile b/5.6/Dockerfile index 6b750c7c..c686ecd1 100644 --- a/5.6/Dockerfile +++ b/5.6/Dockerfile @@ -210,9 +210,6 @@ RUN set -xe; \ apt-get purge -y --auto-remove -o APT::AutoRemove::RecommendsImportant=false $buildDeps >/dev/null; \ apt-get clean; rm -rf /var/lib/apt/lists/* -# Copy mhsendmail binary from stage 1 -COPY --from=mhbuild /go/bin/mhsendmail /usr/local/bin/mhsendmail - ENV COMPOSER_VERSION=1.6.3 \ DRUSH_VERSION=8.1.16 \ DRUSH_LAUNCHER_VERSION=0.6.0 \ From 151b8d9d1685b874bfcfa414cd8bcd9e6d93f368 Mon Sep 17 00:00:00 2001 From: Leonid Makarov Date: Fri, 1 Jun 2018 17:00:32 -0700 Subject: [PATCH 09/45] Cloud9: Dockerfile updates - Set noninteractive mode during the build (package install) process - Cleanup packages - structure Dockerfile similar to the base image files --- cloud9/Dockerfile | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/cloud9/Dockerfile b/cloud9/Dockerfile index bf900540..bc19776f 100644 --- a/cloud9/Dockerfile +++ b/cloud9/Dockerfile @@ -2,15 +2,31 @@ ARG FROM_TAG FROM docksal/cli:${FROM_TAG} +# Set noninteractive mode during the build (package install) process +ARG DEBIAN_FRONTEND=noninteractive + # Cloud9 IDE and dependencies RUN set -x; \ + buildDeps=" \ + g++ \ + make \ + ";\ apt-get update; \ - apt-get install -y tmux g++ make; \ + apt-get -y --force-yes --no-install-recommends install >/dev/null \ + $buildDeps \ + tmux \ + ;\ + \ git clone https://github.com/c9/core.git /opt/c9sdk; \ curl -s -L https://raw.githubusercontent.com/c9/install/master/link.sh | bash; \ /opt/c9sdk/scripts/install-sdk.sh; \ rm -rf /opt/c9sdk/.git; \ - chown -R docker:docker /opt/c9sdk; + chown -R docker:docker /opt/c9sdk; \ + \ + # Cleanup + rm -rf /tmp/pear ~/.pearrc; \ + apt-get purge -y --auto-remove -o APT::AutoRemove::RecommendsImportant=false $buildDeps >/dev/null; \ + apt-get clean; rm -rf /var/lib/apt/lists/*; # Launch Cloud9 via supervisord COPY config/supervisord-cloud9.conf /etc/supervisor/conf.d/cloud9.conf From a13bb6a15df44246ad3ed6e35c031fa8d4ccd6e3 Mon Sep 17 00:00:00 2001 From: Leonid Makarov Date: Fri, 1 Jun 2018 22:12:40 -0700 Subject: [PATCH 10/45] Cloud9 permissions issue fix - Moved c9sdk into /home/docker/c9sdk, since it needs to be able to write into its folder even after UID for the docker users changes at container startup - Install as docker user, so we don't have to fix permissions - clear npm cache (-20MB) --- cloud9/Dockerfile | 25 ++++++++++++++++--------- cloud9/config/supervisord-cloud9.conf | 2 +- 2 files changed, 17 insertions(+), 10 deletions(-) diff --git a/cloud9/Dockerfile b/cloud9/Dockerfile index bc19776f..6278b989 100644 --- a/cloud9/Dockerfile +++ b/cloud9/Dockerfile @@ -5,28 +5,35 @@ FROM docksal/cli:${FROM_TAG} # Set noninteractive mode during the build (package install) process ARG DEBIAN_FRONTEND=noninteractive +# Run as docker, so we don't have to fix permissions +USER docker + +ENV C9SDK_PATH=/home/docker/c9sdk # Cloud9 IDE and dependencies RUN set -x; \ buildDeps=" \ g++ \ make \ ";\ - apt-get update; \ - apt-get -y --force-yes --no-install-recommends install >/dev/null \ + sudo apt-get update; \ + sudo apt-get -y --force-yes --no-install-recommends install >/dev/null \ $buildDeps \ tmux \ ;\ \ - git clone https://github.com/c9/core.git /opt/c9sdk; \ + git clone https://github.com/c9/core.git ${C9SDK_PATH}; \ curl -s -L https://raw.githubusercontent.com/c9/install/master/link.sh | bash; \ - /opt/c9sdk/scripts/install-sdk.sh; \ - rm -rf /opt/c9sdk/.git; \ - chown -R docker:docker /opt/c9sdk; \ + ${C9SDK_PATH}/scripts/install-sdk.sh; \ \ # Cleanup - rm -rf /tmp/pear ~/.pearrc; \ - apt-get purge -y --auto-remove -o APT::AutoRemove::RecommendsImportant=false $buildDeps >/dev/null; \ - apt-get clean; rm -rf /var/lib/apt/lists/*; + rm -rf ${C9SDK_PATH}/.git; \ + npm cache clean --force; \ + sudo apt-get purge -y --auto-remove -o APT::AutoRemove::RecommendsImportant=false $buildDeps >/dev/null; \ + sudo apt-get clean; \ + sudo rm -rf /var/lib/apt/lists/*; + +# Switch back to root (IMPORTANT!) +USER root # Launch Cloud9 via supervisord COPY config/supervisord-cloud9.conf /etc/supervisor/conf.d/cloud9.conf diff --git a/cloud9/config/supervisord-cloud9.conf b/cloud9/config/supervisord-cloud9.conf index bf09b4bc..86d7f9d3 100644 --- a/cloud9/config/supervisord-cloud9.conf +++ b/cloud9/config/supervisord-cloud9.conf @@ -1,6 +1,6 @@ # Cloud9 IDE [program:c9] -command = gosu docker node /opt/c9sdk/server.js -l 0.0.0.0 -p 3000 -w /var/www -a : +command = gosu docker node /home/docker/c9sdk/server.js -l 0.0.0.0 -p 3000 -w /var/www -a : stdout_logfile = /dev/stdout stdout_logfile_maxbytes = 0 stderr_logfile = /dev/stderr From 3f1e897a4e0f2ae2bd68d278881f8b7a8e481bf4 Mon Sep 17 00:00:00 2001 From: Leonid Makarov Date: Fri, 1 Jun 2018 23:55:24 -0700 Subject: [PATCH 11/45] Fix chmod in startup.sh Use 1000:1000 by default if HOST_UID/HOST_GID are not set (e.g. in PWD environments) --- 5.6/startup.sh | 6 +++--- 7.0/startup.sh | 6 +++--- 7.1/startup.sh | 6 +++--- 7.2/startup.sh | 6 +++--- 4 files changed, 12 insertions(+), 12 deletions(-) diff --git a/5.6/startup.sh b/5.6/startup.sh index 1a5ca697..6aad62f1 100755 --- a/5.6/startup.sh +++ b/5.6/startup.sh @@ -68,10 +68,10 @@ render_tmpl "$HOME_DIR/.acquia/cloudapi.conf" # Make sure permissions are correct (after uid/gid change and COPY operations in Dockerfile) # To not bloat the image size, permissions on the home folder are reset at runtime. echo-debug "Resetting permissions on $HOME_DIR and /var/www..." -chown "$HOST_UID:$HOST_GID" -R "$HOME_DIR" +chown "${HOST_UID-:1000}:${HOST_GID:-1000}" -R "$HOME_DIR" # Docker resets the project root folder permissions to 0:0 when cli is recreated (e.g. an env variable updated). -# We apply a fix/workaround for this at startup. -chown "$HOST_UID:$HOST_GID" /var/www +# We apply a fix/workaround for this at startup (non-recursive). +chown "${HOST_UID-:1000}:${HOST_GID:-1000}" /var/www # Initialization steps completed. Create a pid file to mark the container as healthy echo-debug "Preliminary initialization completed" diff --git a/7.0/startup.sh b/7.0/startup.sh index 1a5ca697..6aad62f1 100755 --- a/7.0/startup.sh +++ b/7.0/startup.sh @@ -68,10 +68,10 @@ render_tmpl "$HOME_DIR/.acquia/cloudapi.conf" # Make sure permissions are correct (after uid/gid change and COPY operations in Dockerfile) # To not bloat the image size, permissions on the home folder are reset at runtime. echo-debug "Resetting permissions on $HOME_DIR and /var/www..." -chown "$HOST_UID:$HOST_GID" -R "$HOME_DIR" +chown "${HOST_UID-:1000}:${HOST_GID:-1000}" -R "$HOME_DIR" # Docker resets the project root folder permissions to 0:0 when cli is recreated (e.g. an env variable updated). -# We apply a fix/workaround for this at startup. -chown "$HOST_UID:$HOST_GID" /var/www +# We apply a fix/workaround for this at startup (non-recursive). +chown "${HOST_UID-:1000}:${HOST_GID:-1000}" /var/www # Initialization steps completed. Create a pid file to mark the container as healthy echo-debug "Preliminary initialization completed" diff --git a/7.1/startup.sh b/7.1/startup.sh index 1a5ca697..6aad62f1 100755 --- a/7.1/startup.sh +++ b/7.1/startup.sh @@ -68,10 +68,10 @@ render_tmpl "$HOME_DIR/.acquia/cloudapi.conf" # Make sure permissions are correct (after uid/gid change and COPY operations in Dockerfile) # To not bloat the image size, permissions on the home folder are reset at runtime. echo-debug "Resetting permissions on $HOME_DIR and /var/www..." -chown "$HOST_UID:$HOST_GID" -R "$HOME_DIR" +chown "${HOST_UID-:1000}:${HOST_GID:-1000}" -R "$HOME_DIR" # Docker resets the project root folder permissions to 0:0 when cli is recreated (e.g. an env variable updated). -# We apply a fix/workaround for this at startup. -chown "$HOST_UID:$HOST_GID" /var/www +# We apply a fix/workaround for this at startup (non-recursive). +chown "${HOST_UID-:1000}:${HOST_GID:-1000}" /var/www # Initialization steps completed. Create a pid file to mark the container as healthy echo-debug "Preliminary initialization completed" diff --git a/7.2/startup.sh b/7.2/startup.sh index 1a5ca697..6aad62f1 100755 --- a/7.2/startup.sh +++ b/7.2/startup.sh @@ -68,10 +68,10 @@ render_tmpl "$HOME_DIR/.acquia/cloudapi.conf" # Make sure permissions are correct (after uid/gid change and COPY operations in Dockerfile) # To not bloat the image size, permissions on the home folder are reset at runtime. echo-debug "Resetting permissions on $HOME_DIR and /var/www..." -chown "$HOST_UID:$HOST_GID" -R "$HOME_DIR" +chown "${HOST_UID-:1000}:${HOST_GID:-1000}" -R "$HOME_DIR" # Docker resets the project root folder permissions to 0:0 when cli is recreated (e.g. an env variable updated). -# We apply a fix/workaround for this at startup. -chown "$HOST_UID:$HOST_GID" /var/www +# We apply a fix/workaround for this at startup (non-recursive). +chown "${HOST_UID-:1000}:${HOST_GID:-1000}" /var/www # Initialization steps completed. Create a pid file to mark the container as healthy echo-debug "Preliminary initialization completed" From f0d9c488926432b353a924a7d618df5bca17d867 Mon Sep 17 00:00:00 2001 From: Leonid Makarov Date: Fri, 22 Jun 2018 15:42:14 -0700 Subject: [PATCH 12/45] Updated comment in php configs Point to the correct config file for PHP FPM overrides [ci skip] --- 5.6/config/php/zz-php.ini | 2 +- 7.0/config/php/zz-php.ini | 2 +- 7.1/config/php/zz-php.ini | 2 +- 7.2/config/php/zz-php.ini | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/5.6/config/php/zz-php.ini b/5.6/config/php/zz-php.ini index d521ad93..cc51d5c0 100644 --- a/5.6/config/php/zz-php.ini +++ b/5.6/config/php/zz-php.ini @@ -1,5 +1,5 @@ ; PHP global (CLI and FPM) settings -; To override settings for FPM use docksal-www.conf +; To override settings for FPM use zz-php-fpm.conf [php] memory_limit = 1024M max_execution_time = 600 diff --git a/7.0/config/php/zz-php.ini b/7.0/config/php/zz-php.ini index 2da599b5..0b1aff21 100644 --- a/7.0/config/php/zz-php.ini +++ b/7.0/config/php/zz-php.ini @@ -1,5 +1,5 @@ ; PHP global (CLI and FPM) settings -; To override settings for FPM use docksal-www.conf +; To override settings for FPM use zz-php-fpm.conf [php] memory_limit = 1024M max_execution_time = 600 diff --git a/7.1/config/php/zz-php.ini b/7.1/config/php/zz-php.ini index 2da599b5..0b1aff21 100644 --- a/7.1/config/php/zz-php.ini +++ b/7.1/config/php/zz-php.ini @@ -1,5 +1,5 @@ ; PHP global (CLI and FPM) settings -; To override settings for FPM use docksal-www.conf +; To override settings for FPM use zz-php-fpm.conf [php] memory_limit = 1024M max_execution_time = 600 diff --git a/7.2/config/php/zz-php.ini b/7.2/config/php/zz-php.ini index 2da599b5..0b1aff21 100644 --- a/7.2/config/php/zz-php.ini +++ b/7.2/config/php/zz-php.ini @@ -1,5 +1,5 @@ ; PHP global (CLI and FPM) settings -; To override settings for FPM use docksal-www.conf +; To override settings for FPM use zz-php-fpm.conf [php] memory_limit = 1024M max_execution_time = 600 From abf281a4e7fe1d61a649baeb9fb8fd29fe1997d3 Mon Sep 17 00:00:00 2001 From: Leonid Makarov Date: Fri, 22 Jun 2018 15:41:17 -0700 Subject: [PATCH 13/45] Make sure the latest release and stable tags match. Closes #56 - Moved the push script into a standalone file - scripts/docker-push.sh - Refactored and optimized the script logic --- .travis.yml | 24 +------------ scripts/docker-push.sh | 79 ++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 80 insertions(+), 23 deletions(-) create mode 100755 scripts/docker-push.sh diff --git a/.travis.yml b/.travis.yml index ee8d56cf..1ca4040d 100644 --- a/.travis.yml +++ b/.travis.yml @@ -32,29 +32,7 @@ script: after_success: - docker image ls - - | - if [[ "${TRAVIS_PULL_REQUEST}" == "false" ]]; then - [[ "${TRAVIS_BRANCH}" == "develop" ]] && TAG="edge-php${VERSION}" - [[ "${TRAVIS_BRANCH}" == "master" ]] && TAG="php${VERSION}" - [[ "${TRAVIS_TAG}" != "" ]] && TAG="${TRAVIS_TAG:1:3}-php${VERSION}" - - if [[ "$TAG" != "" ]]; then - docker login -u "${DOCKER_USER}" -p "${DOCKER_PASS}" - # Push edge, stable and release tags - # Base image - docker tag ${REPO}:build-${VERSION} ${REPO}:${TAG} - docker push ${REPO}:${TAG} - # Cloud9 flavor - docker tag ${REPO}:build-${VERSION}-ide ${REPO}:${TAG}-ide - docker push ${REPO}:${TAG}-ide - - # Push "latest" tag - if [[ "${TRAVIS_BRANCH}" == "master" ]] && [[ "${VERSION}" == "${LATEST_VERSION}" ]]; then - docker tag ${REPO}:build-${VERSION} ${REPO}:latest - docker push ${REPO}:latest - fi - fi - fi + - scripts/docker-push.sh after_failure: - cd ${TRAVIS_BUILD_DIR}/${VERSION} && make logs diff --git a/scripts/docker-push.sh b/scripts/docker-push.sh new file mode 100755 index 00000000..cd10dd7d --- /dev/null +++ b/scripts/docker-push.sh @@ -0,0 +1,79 @@ +#!/usr/bin/env bash + +# ----- Helper functions ----- # + +is_edge () +{ + [[ "${TRAVIS_BRANCH}" == "develop" ]] +} + +is_stable () +{ + [[ "${TRAVIS_BRANCH}" == "master" ]] +} + +is_release () +{ + [[ "${TRAVIS_TAG}" != "" ]] +} + +# Check whether the current build is for a pull request +is_pr () +{ + [[ "${TRAVIS_PULL_REQUEST}" == "false" ]] +} + +is_latest () +{ + [[ "${VERSION}" == "${LATEST_VERSION}" ]] +} + +# Tag and push an image +tag_and_push () +{ + local source=$1 + local target=$2 + + # Base image + docker tag ${source} ${target} + docker push ${target} + + # Cloud9 flavor + docker tag ${source}-ide ${target}-ide + docker push ${target}-ide +} + +# ---------------------------- # + +# Possible docker image tags +IMAGE_TAG_EDGE="edge-php${VERSION}" +IMAGE_TAG_STABLE="php${VERSION}" +IMAGE_TAG_RELEASE="${TRAVIS_TAG:1:3}-php${VERSION}" +IMAGE_TAG_LATEST="latest" + +# Skip pull request builds +is_pr && exit + +# Figure out which docker image tag to use +if is_edge; then + IMAGE_TAG=${IMAGE_TAG_EDGE} +elif is_stable; then + IMAGE_TAG=${IMAGE_TAG_STABLE} +elif is_release; then + IMAGE_TAG=${IMAGE_TAG_RELEASE} +else + # Exit if not on develop, master or release tag + exit +fi + +docker login -u "${DOCKER_USER}" -p "${DOCKER_PASS}" + +# Push images +tag_and_push ${REPO}:build-${VERSION} ${REPO}:${IMAGE_TAG} + +# Special case for the "latest" tag +# Push (base image only) on stable and release builds +if is_latest && (is_stable || is_release); then + docker tag ${REPO}:build-${VERSION} ${REPO}:${IMAGE_TAG_LATEST} + docker push ${REPO}:${IMAGE_TAG_LATEST} +fi From d3a3fbfec8f9b91a0b27021baa33e5e2c85e18d4 Mon Sep 17 00:00:00 2001 From: Leonid Makarov Date: Fri, 22 Jun 2018 16:46:21 -0700 Subject: [PATCH 14/45] Updated docksal install command - Using bash - Added DOCKSAL_VERSION to add an option to override the version via build variables --- .travis.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 1ca4040d..d5ddeab7 100644 --- a/.travis.yml +++ b/.travis.yml @@ -7,6 +7,7 @@ env: global: - REPO=docksal/cli - LATEST_VERSION=7.2 + - DOCKSAL_VERSION=master matrix: - VERSION=5.6 - VERSION=7.0 @@ -18,7 +19,7 @@ before_install: - sudo apt-get install libfcgi0ldbl # cgi-fcgi binary used in tests install: - - curl -fsSL https://get.docksal.io | sh + - curl -fsSL https://get.docksal.io | DOCKSAL_VERSION=${DOCKSAL_VERSION} bash - fin version - fin sysinfo From bd1eddcb36cd473d3c21cb97750a7c8259306478 Mon Sep 17 00:00:00 2001 From: Leonid Makarov Date: Fri, 22 Jun 2018 16:48:05 -0700 Subject: [PATCH 15/45] Added parameter description for tag_and_push [ci skip] --- scripts/docker-push.sh | 2 ++ 1 file changed, 2 insertions(+) diff --git a/scripts/docker-push.sh b/scripts/docker-push.sh index cd10dd7d..2a4278fd 100755 --- a/scripts/docker-push.sh +++ b/scripts/docker-push.sh @@ -29,6 +29,8 @@ is_latest () } # Tag and push an image +# $1 - source image +# $2 - target image tag_and_push () { local source=$1 From c5fc49cfde9005464b237473e4b98aac7f1bac10 Mon Sep 17 00:00:00 2001 From: Sean Dietrich Date: Mon, 25 Jun 2018 10:04:40 -0700 Subject: [PATCH 16/45] Added Platform.sh CLI Tool Integration (#54) * Added Platform.sh cli tool * Added a generic secret variable conversion function (`SECRET_VAR1` => `VAR1`) * Added integration to test Platform.sh * Updated Terminus to 1.8.1 * Updated README.md --- 5.6/Dockerfile | 6 +++++- 5.6/startup.sh | 20 ++++++++++++++++++++ 7.0/Dockerfile | 6 +++++- 7.0/startup.sh | 20 ++++++++++++++++++++ 7.1/Dockerfile | 6 +++++- 7.1/startup.sh | 20 ++++++++++++++++++++ 7.2/Dockerfile | 6 +++++- 7.2/startup.sh | 20 ++++++++++++++++++++ README.md | 8 ++++++++ tests/test.bats | 40 ++++++++++++++++++++++++++++++++++++++++ 10 files changed, 148 insertions(+), 4 deletions(-) diff --git a/5.6/Dockerfile b/5.6/Dockerfile index 84014088..a4df69ba 100644 --- a/5.6/Dockerfile +++ b/5.6/Dockerfile @@ -275,7 +275,9 @@ ENV HOME /home/docker ENV PATH=$PATH:$HOME/.composer/vendor/bin \ DRUSH_LAUNCHER_FALLBACK=/usr/local/bin/drush8 ENV PATH=$PATH:$HOME/.terminus/vendor/bin \ - TERMINUS_VERSION=1.8.0 + TERMINUS_VERSION=1.8.1 +ENV PATH=$PATH:$HOME/.platformsh \ + PLATFORMSH_CLI_VERSION=3.33.5 RUN set -xe; \ # Add composer bin directory to PATH echo "\n"'PATH="$PATH:$HOME/.composer/vendor/bin"' >> $HOME/.profile; \ @@ -293,6 +295,8 @@ RUN set -xe; \ mkdir -p $HOME/.terminus; \ # Run in a subshell since we are doing directory switching (cd $HOME/.terminus && composer require pantheon-systems/terminus:${TERMINUS_VERSION}); \ + mkdir -p $HOME/.platformsh; \ + (cd $HOME/.platformsh && curl -o platform -L "https://github.com/platformsh/platformsh-cli/releases/download/v${PLATFORMSH_CLI_VERSION}/platform.phar" && chmod 755 platform); \ # Cleanup composer clear-cache diff --git a/5.6/startup.sh b/5.6/startup.sh index 6aad62f1..34a9b2fc 100755 --- a/5.6/startup.sh +++ b/5.6/startup.sh @@ -43,6 +43,20 @@ render_tmpl () fi } +# Helper function to loop through all environment variables prefixed with SECRET_ and +# convert to the equivalent variable without SECRET. (ex SECRET_TERMINUS_TOKEN has a variable +# called TERMINUS_TOKEN. +convert_secrets () +{ + eval 'secrets=(${!SECRET_@})' + for secret_key in "${secrets[@]}" + do + secret_value=${!secret_key} + key=${secret_key#SECRET_} + echo "export ${key}=\"${secret_value}\";" | sudo -u docker tee -a ~/.docksalrc + done +} + terminus_login () { echo-debug "Authenticating with Pantheon..." @@ -59,6 +73,12 @@ render_tmpl "$HOME_DIR/.acquia/cloudapi.conf" # Terminus authentication [[ "$SECRET_TERMINUS_TOKEN" ]] && terminus_login +# Convert all Environment Variables Prefixed with SECRET_ +convert_secrets + +# Source Docksalrc for when someone runs bash in the container +echo "source ~/.docksalrc" | sudo -u docker tee -a ~/.bashrc + # Docker user uid/gid mapping to the host user uid/gid [[ "$HOST_UID" != "" ]] && [[ "$HOST_GID" != "" ]] && uid_gid_reset diff --git a/7.0/Dockerfile b/7.0/Dockerfile index 3083ce11..5e5acc05 100644 --- a/7.0/Dockerfile +++ b/7.0/Dockerfile @@ -284,7 +284,9 @@ ENV HOME /home/docker ENV PATH=$PATH:$HOME/.composer/vendor/bin \ DRUSH_LAUNCHER_FALLBACK=/usr/local/bin/drush8 ENV PATH=$PATH:$HOME/.terminus/vendor/bin \ - TERMINUS_VERSION=1.8.0 + TERMINUS_VERSION=1.8.1 +ENV PATH=$PATH:$HOME/.platformsh \ + PLATFORMSH_CLI_VERSION=3.33.5 RUN set -xe; \ # Add composer bin directory to PATH echo "\n"'PATH="$PATH:$HOME/.composer/vendor/bin"' >> $HOME/.profile; \ @@ -302,6 +304,8 @@ RUN set -xe; \ mkdir -p $HOME/.terminus; \ # Run in a subshell since we are doing directory switching (cd $HOME/.terminus && composer require pantheon-systems/terminus:${TERMINUS_VERSION}); \ + mkdir -p $HOME/.platformsh; \ + (cd $HOME/.platformsh && curl -o platform -L "https://github.com/platformsh/platformsh-cli/releases/download/v${PLATFORMSH_CLI_VERSION}/platform.phar" && chmod 755 platform); \ # Cleanup composer clear-cache diff --git a/7.0/startup.sh b/7.0/startup.sh index 6aad62f1..34a9b2fc 100755 --- a/7.0/startup.sh +++ b/7.0/startup.sh @@ -43,6 +43,20 @@ render_tmpl () fi } +# Helper function to loop through all environment variables prefixed with SECRET_ and +# convert to the equivalent variable without SECRET. (ex SECRET_TERMINUS_TOKEN has a variable +# called TERMINUS_TOKEN. +convert_secrets () +{ + eval 'secrets=(${!SECRET_@})' + for secret_key in "${secrets[@]}" + do + secret_value=${!secret_key} + key=${secret_key#SECRET_} + echo "export ${key}=\"${secret_value}\";" | sudo -u docker tee -a ~/.docksalrc + done +} + terminus_login () { echo-debug "Authenticating with Pantheon..." @@ -59,6 +73,12 @@ render_tmpl "$HOME_DIR/.acquia/cloudapi.conf" # Terminus authentication [[ "$SECRET_TERMINUS_TOKEN" ]] && terminus_login +# Convert all Environment Variables Prefixed with SECRET_ +convert_secrets + +# Source Docksalrc for when someone runs bash in the container +echo "source ~/.docksalrc" | sudo -u docker tee -a ~/.bashrc + # Docker user uid/gid mapping to the host user uid/gid [[ "$HOST_UID" != "" ]] && [[ "$HOST_GID" != "" ]] && uid_gid_reset diff --git a/7.1/Dockerfile b/7.1/Dockerfile index 50c20a82..db9e911b 100644 --- a/7.1/Dockerfile +++ b/7.1/Dockerfile @@ -284,7 +284,9 @@ ENV HOME /home/docker ENV PATH=$PATH:$HOME/.composer/vendor/bin \ DRUSH_LAUNCHER_FALLBACK=/usr/local/bin/drush8 ENV PATH=$PATH:$HOME/.terminus/vendor/bin \ - TERMINUS_VERSION=1.8.0 + TERMINUS_VERSION=1.8.1 +ENV PATH=$PATH:$HOME/.platformsh \ + PLATFORMSH_CLI_VERSION=3.33.5 RUN set -xe; \ # Add composer bin directory to PATH echo "\n"'PATH="$PATH:$HOME/.composer/vendor/bin"' >> $HOME/.profile; \ @@ -302,6 +304,8 @@ RUN set -xe; \ mkdir -p $HOME/.terminus; \ # Run in a subshell since we are doing directory switching (cd $HOME/.terminus && composer require pantheon-systems/terminus:${TERMINUS_VERSION}); \ + mkdir -p $HOME/.platformsh; \ + (cd $HOME/.platformsh && curl -o platform -L "https://github.com/platformsh/platformsh-cli/releases/download/v${PLATFORMSH_CLI_VERSION}/platform.phar" && chmod 755 platform); \ # Cleanup composer clear-cache diff --git a/7.1/startup.sh b/7.1/startup.sh index 6aad62f1..34a9b2fc 100755 --- a/7.1/startup.sh +++ b/7.1/startup.sh @@ -43,6 +43,20 @@ render_tmpl () fi } +# Helper function to loop through all environment variables prefixed with SECRET_ and +# convert to the equivalent variable without SECRET. (ex SECRET_TERMINUS_TOKEN has a variable +# called TERMINUS_TOKEN. +convert_secrets () +{ + eval 'secrets=(${!SECRET_@})' + for secret_key in "${secrets[@]}" + do + secret_value=${!secret_key} + key=${secret_key#SECRET_} + echo "export ${key}=\"${secret_value}\";" | sudo -u docker tee -a ~/.docksalrc + done +} + terminus_login () { echo-debug "Authenticating with Pantheon..." @@ -59,6 +73,12 @@ render_tmpl "$HOME_DIR/.acquia/cloudapi.conf" # Terminus authentication [[ "$SECRET_TERMINUS_TOKEN" ]] && terminus_login +# Convert all Environment Variables Prefixed with SECRET_ +convert_secrets + +# Source Docksalrc for when someone runs bash in the container +echo "source ~/.docksalrc" | sudo -u docker tee -a ~/.bashrc + # Docker user uid/gid mapping to the host user uid/gid [[ "$HOST_UID" != "" ]] && [[ "$HOST_GID" != "" ]] && uid_gid_reset diff --git a/7.2/Dockerfile b/7.2/Dockerfile index 49d899f6..734856b6 100644 --- a/7.2/Dockerfile +++ b/7.2/Dockerfile @@ -286,7 +286,9 @@ ENV HOME /home/docker ENV PATH=$PATH:$HOME/.composer/vendor/bin \ DRUSH_LAUNCHER_FALLBACK=/usr/local/bin/drush8 ENV PATH=$PATH:$HOME/.terminus/vendor/bin \ - TERMINUS_VERSION=1.8.0 + TERMINUS_VERSION=1.8.1 +ENV PATH=$PATH:$HOME/.platformsh \ + PLATFORMSH_CLI_VERSION=3.33.5 RUN set -xe; \ # Add composer bin directory to PATH echo "\n"'PATH="$PATH:$HOME/.composer/vendor/bin"' >> $HOME/.profile; \ @@ -304,6 +306,8 @@ RUN set -xe; \ mkdir -p $HOME/.terminus; \ # Run in a subshell since we are doing directory switching (cd $HOME/.terminus && composer require pantheon-systems/terminus:${TERMINUS_VERSION}); \ + mkdir -p $HOME/.platformsh; \ + (cd $HOME/.platformsh && curl -o platform -L "https://github.com/platformsh/platformsh-cli/releases/download/v${PLATFORMSH_CLI_VERSION}/platform.phar" && chmod 755 platform); \ # Cleanup composer clear-cache diff --git a/7.2/startup.sh b/7.2/startup.sh index 6aad62f1..34a9b2fc 100755 --- a/7.2/startup.sh +++ b/7.2/startup.sh @@ -43,6 +43,20 @@ render_tmpl () fi } +# Helper function to loop through all environment variables prefixed with SECRET_ and +# convert to the equivalent variable without SECRET. (ex SECRET_TERMINUS_TOKEN has a variable +# called TERMINUS_TOKEN. +convert_secrets () +{ + eval 'secrets=(${!SECRET_@})' + for secret_key in "${secrets[@]}" + do + secret_value=${!secret_key} + key=${secret_key#SECRET_} + echo "export ${key}=\"${secret_value}\";" | sudo -u docker tee -a ~/.docksalrc + done +} + terminus_login () { echo-debug "Authenticating with Pantheon..." @@ -59,6 +73,12 @@ render_tmpl "$HOME_DIR/.acquia/cloudapi.conf" # Terminus authentication [[ "$SECRET_TERMINUS_TOKEN" ]] && terminus_login +# Convert all Environment Variables Prefixed with SECRET_ +convert_secrets + +# Source Docksalrc for when someone runs bash in the container +echo "source ~/.docksalrc" | sudo -u docker tee -a ~/.bashrc + # Docker user uid/gid mapping to the host user uid/gid [[ "$HOST_UID" != "" ]] && [[ "$HOST_GID" != "" ]] && uid_gid_reset diff --git a/README.md b/README.md index e316264d..5c42173c 100644 --- a/README.md +++ b/README.md @@ -31,6 +31,7 @@ This image(s) is part of the [Docksal](http://docksal.io) image library. - Acquia Cloud API commands - drupal console launcher - terminus (Pantheon) + - platform (Platform.sh) - wp-cli - ruby - ruby @@ -106,3 +107,10 @@ Credentials used to authenticate [Terminus](https://pantheon.io/docs/terminus) w Stored in `/home/docker/.terminus/` inside `cli`. Terminus is installed and available globally in `cli`. + +`SECRET_PLATFORMSH_CLI_TOKEN` + +Credentials used to authenticate with the [Platform.sh CLI](https://github.com/platformsh/platformsh-cli) tool. +Stored in `/home/docker/.platform` inside `cli`. + +Platform CLI is installed and available globally in `cli`. diff --git a/tests/test.bats b/tests/test.bats index db5910f8..9eb98b84 100755 --- a/tests/test.bats +++ b/tests/test.bats @@ -215,6 +215,11 @@ _healthcheck_wait () [[ ${status} == 0 ]] unset output + # Check Platform CLI version + run docker exec -u docker "$NAME" bash -c 'platform --version | grep "Platform.sh CLI ${PLATFORMSH_CLI_VERSION}"' + [[ ${status} == 0 ]] + unset output + ### Cleanup ### docker rm -vf "$NAME" >/dev/null 2>&1 || true } @@ -258,3 +263,38 @@ _healthcheck_wait () fin rm -f rm -f .docksal/docksal-local.env } + +@test "Check Platform.sh Integration" { + [[ $SKIP == 1 ]] && skip + + ### Setup ### + docker rm -vf "$NAME" >/dev/null 2>&1 || true + docker run --name "$NAME" -d \ + -v /home/docker \ + -v $(pwd)/../tests:/var/www \ + -e SECRET_PLATFORMSH_CLI_TOKEN \ + "$IMAGE" + _healthcheck_wait + + ### Tests ### + + # Confirm output is not empty and token is passed to container + run docker exec -it -u docker "$NAME" bash -c 'source $HOME/.docksalrc >/dev/null 2>&1; echo "${SECRET_PLATFORMSH_CLI_TOKEN}"' + [[ "${output}" != "" ]] + unset output + + # Confirm token passed to container was converted without SECRET_ + run fin exec 'echo ${PLATFORMSH_CLI_TOKEN}' + [[ "${output}" != "" ]] + unset output + + # Confirm Authentication + run docker exec -it -u docker "$NAME" bash -c 'source $HOME/.docksalrc >/dev/null 2>&1; platform auth:info -n' + [[ ${status} == 0 ]] && + [[ ! "${output}" =~ "Invalid API token" ]] && + [[ "${output}" =~ "Docksal App" ]] && + unset output + + ### Cleanup ### + docker rm -vf "$NAME" >/dev/null 2>&1 || true +} From 284b208e547f107faeb92999b723ed1608540d62 Mon Sep 17 00:00:00 2001 From: Sean Dietrich Date: Thu, 28 Jun 2018 10:57:03 -0700 Subject: [PATCH 17/45] Added ability for custom startup script (#55) --- 5.6/startup.sh | 6 ++++++ 7.0/startup.sh | 6 ++++++ 7.1/startup.sh | 6 ++++++ 7.2/startup.sh | 6 ++++++ README.md | 5 +++++ tests/.docksal/services/cli/startup.sh | 3 +++ tests/test.bats | 12 ++++++++++++ 7 files changed, 44 insertions(+) create mode 100755 tests/.docksal/services/cli/startup.sh diff --git a/5.6/startup.sh b/5.6/startup.sh index 34a9b2fc..97bfbaa4 100755 --- a/5.6/startup.sh +++ b/5.6/startup.sh @@ -97,6 +97,12 @@ chown "${HOST_UID-:1000}:${HOST_GID:-1000}" /var/www echo-debug "Preliminary initialization completed" touch /var/run/cli +if [[ -x ${PROJECT_ROOT}/.docksal/services/cli/startup.sh ]]; then + echo-debug "Running Custom Startup Script..." + ${PROJECT_ROOT}/.docksal/services/cli/startup.sh + echo-debug "Custom Startup Script Complete..." +fi + # Execute passed CMD arguments echo-debug "Executing the requested command..." # Service mode (run as root) diff --git a/7.0/startup.sh b/7.0/startup.sh index 34a9b2fc..97bfbaa4 100755 --- a/7.0/startup.sh +++ b/7.0/startup.sh @@ -97,6 +97,12 @@ chown "${HOST_UID-:1000}:${HOST_GID:-1000}" /var/www echo-debug "Preliminary initialization completed" touch /var/run/cli +if [[ -x ${PROJECT_ROOT}/.docksal/services/cli/startup.sh ]]; then + echo-debug "Running Custom Startup Script..." + ${PROJECT_ROOT}/.docksal/services/cli/startup.sh + echo-debug "Custom Startup Script Complete..." +fi + # Execute passed CMD arguments echo-debug "Executing the requested command..." # Service mode (run as root) diff --git a/7.1/startup.sh b/7.1/startup.sh index 34a9b2fc..97bfbaa4 100755 --- a/7.1/startup.sh +++ b/7.1/startup.sh @@ -97,6 +97,12 @@ chown "${HOST_UID-:1000}:${HOST_GID:-1000}" /var/www echo-debug "Preliminary initialization completed" touch /var/run/cli +if [[ -x ${PROJECT_ROOT}/.docksal/services/cli/startup.sh ]]; then + echo-debug "Running Custom Startup Script..." + ${PROJECT_ROOT}/.docksal/services/cli/startup.sh + echo-debug "Custom Startup Script Complete..." +fi + # Execute passed CMD arguments echo-debug "Executing the requested command..." # Service mode (run as root) diff --git a/7.2/startup.sh b/7.2/startup.sh index 34a9b2fc..97bfbaa4 100755 --- a/7.2/startup.sh +++ b/7.2/startup.sh @@ -97,6 +97,12 @@ chown "${HOST_UID-:1000}:${HOST_GID:-1000}" /var/www echo-debug "Preliminary initialization completed" touch /var/run/cli +if [[ -x ${PROJECT_ROOT}/.docksal/services/cli/startup.sh ]]; then + echo-debug "Running Custom Startup Script..." + ${PROJECT_ROOT}/.docksal/services/cli/startup.sh + echo-debug "Custom Startup Script Complete..." +fi + # Execute passed CMD arguments echo-debug "Executing the requested command..." # Service mode (run as root) diff --git a/README.md b/README.md index 5c42173c..40179dda 100644 --- a/README.md +++ b/README.md @@ -78,6 +78,11 @@ cli See [docs](https://docs.docksal.io/en/master/tools/xdebug) on using Xdebug for web and cli PHP debugging. +## Customizing Startup + +To run a custom startup script anytime the `cli` container has started create a `startup.sh` file within the +`.docksal/services/cli` directory. Additionally, make sure that the file is executable as well so that the container +does not run into issues when attempting to execute the file. ## Secrets and integrations diff --git a/tests/.docksal/services/cli/startup.sh b/tests/.docksal/services/cli/startup.sh new file mode 100755 index 00000000..1966ead3 --- /dev/null +++ b/tests/.docksal/services/cli/startup.sh @@ -0,0 +1,3 @@ +#!/bin/bash + +echo "I ran properly" > /tmp/test-startup.txt diff --git a/tests/test.bats b/tests/test.bats index 9eb98b84..f9cc65f4 100755 --- a/tests/test.bats +++ b/tests/test.bats @@ -264,6 +264,18 @@ _healthcheck_wait () rm -f .docksal/docksal-local.env } +@test "Check Custom Startup Script Works" { + [[ $SKIP == 1 ]] && skip + + cd ../tests + echo "CLI_IMAGE=\"${IMAGE}\"" > .docksal/docksal-local.env + fin reset -f + + run fin exec -T 'cat /tmp/test-startup.txt' + [[ ${status} == 0 ]] && + [[ "${output}" =~ "I ran properly" ]] +} + @test "Check Platform.sh Integration" { [[ $SKIP == 1 ]] && skip From 43661762ff3f6b957f3a2330a85f5760a65c745e Mon Sep 17 00:00:00 2001 From: Sean Dietrich Date: Thu, 28 Jun 2018 14:15:56 -0700 Subject: [PATCH 18/45] Added Terminus test (#59) * Added test to confirm Terminus is working correctly in the container --- tests/test.bats | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/tests/test.bats b/tests/test.bats index f9cc65f4..63982e52 100755 --- a/tests/test.bats +++ b/tests/test.bats @@ -310,3 +310,33 @@ _healthcheck_wait () ### Cleanup ### docker rm -vf "$NAME" >/dev/null 2>&1 || true } + +@test "Check Pantheon Integration" { + [[ $SKIP == 1 ]] && skip + + ### Setup ### + docker rm -vf "$NAME" >/dev/null 2>&1 || true + docker run --name "$NAME" -d \ + -v /home/docker \ + -v $(pwd)/../tests:/var/www \ + -e SECRET_TERMINUS_TOKEN \ + "$IMAGE" + _healthcheck_wait + + ### Tests ### + + # Confirm output is not empty and token is passed to container + run docker exec -it -u docker "$NAME" bash -c 'source $HOME/.docksalrc >/dev/null 2>&1; echo "${SECRET_TERMINUS_TOKEN}"' + [[ "${output}" =~ "${SECRET_TERMINUS_TOKEN}" ]] + unset output + + # Confirm Authentication + run docker exec -it -u docker "$NAME" bash -c 'source $HOME/.docksalrc >/dev/null 2>&1; terminus auth:whoami' + [[ ${status} == 0 ]] && + [[ ! "${output}" =~ "You are not logged in." ]] && + [[ "${output}" =~ "developer@docksal.io" ]] && + unset output + + ### Cleanup ### + docker rm -vf "$NAME" >/dev/null 2>&1 || true +} From 7f5c69f34b5ac31cb65086030009820609be3a1a Mon Sep 17 00:00:00 2001 From: Sean Dietrich Date: Tue, 3 Jul 2018 09:41:32 -0700 Subject: [PATCH 19/45] Added ability for cron to be set up on the project level (#64) --- 5.6/config/supervisord.conf | 7 ++++++ 5.6/startup.sh | 5 ++++ 7.0/config/supervisord.conf | 7 ++++++ 7.0/startup.sh | 5 ++++ 7.1/config/supervisord.conf | 7 ++++++ 7.1/startup.sh | 5 ++++ 7.2/config/supervisord.conf | 7 ++++++ 7.2/startup.sh | 5 ++++ README.md | 6 +++++ tests/.docksal/services/cli/crontab | 1 + tests/test.bats | 39 +++++++++++++++++++++++++++++ 11 files changed, 94 insertions(+) create mode 100644 tests/.docksal/services/cli/crontab diff --git a/5.6/config/supervisord.conf b/5.6/config/supervisord.conf index 1ae1f475..574eeff5 100644 --- a/5.6/config/supervisord.conf +++ b/5.6/config/supervisord.conf @@ -15,3 +15,10 @@ stdout_logfile = /dev/stdout stdout_logfile_maxbytes = 0 stderr_logfile = /dev/stderr stderr_logfile_maxbytes = 0 + +[program:cron] +command = /usr/sbin/cron +stdout_logfile = /dev/stdout +stdout_logfile_maxbytes = 0 +stderr_logfile = /dev/stderr +stderr_logfile_maxbytes = 0 diff --git a/5.6/startup.sh b/5.6/startup.sh index 97bfbaa4..79b7cb84 100755 --- a/5.6/startup.sh +++ b/5.6/startup.sh @@ -97,6 +97,11 @@ chown "${HOST_UID-:1000}:${HOST_GID:-1000}" /var/www echo-debug "Preliminary initialization completed" touch /var/run/cli +# If crontab file is found within project add contents to user crontab file. +if [[ -f ${PROJECT_ROOT}/.docksal/services/cli/crontab ]]; then + cat ${PROJECT_ROOT}/.docksal/services/cli/crontab | crontab -u docker - +fi + if [[ -x ${PROJECT_ROOT}/.docksal/services/cli/startup.sh ]]; then echo-debug "Running Custom Startup Script..." ${PROJECT_ROOT}/.docksal/services/cli/startup.sh diff --git a/7.0/config/supervisord.conf b/7.0/config/supervisord.conf index 1ae1f475..574eeff5 100644 --- a/7.0/config/supervisord.conf +++ b/7.0/config/supervisord.conf @@ -15,3 +15,10 @@ stdout_logfile = /dev/stdout stdout_logfile_maxbytes = 0 stderr_logfile = /dev/stderr stderr_logfile_maxbytes = 0 + +[program:cron] +command = /usr/sbin/cron +stdout_logfile = /dev/stdout +stdout_logfile_maxbytes = 0 +stderr_logfile = /dev/stderr +stderr_logfile_maxbytes = 0 diff --git a/7.0/startup.sh b/7.0/startup.sh index 97bfbaa4..79b7cb84 100755 --- a/7.0/startup.sh +++ b/7.0/startup.sh @@ -97,6 +97,11 @@ chown "${HOST_UID-:1000}:${HOST_GID:-1000}" /var/www echo-debug "Preliminary initialization completed" touch /var/run/cli +# If crontab file is found within project add contents to user crontab file. +if [[ -f ${PROJECT_ROOT}/.docksal/services/cli/crontab ]]; then + cat ${PROJECT_ROOT}/.docksal/services/cli/crontab | crontab -u docker - +fi + if [[ -x ${PROJECT_ROOT}/.docksal/services/cli/startup.sh ]]; then echo-debug "Running Custom Startup Script..." ${PROJECT_ROOT}/.docksal/services/cli/startup.sh diff --git a/7.1/config/supervisord.conf b/7.1/config/supervisord.conf index 1ae1f475..574eeff5 100644 --- a/7.1/config/supervisord.conf +++ b/7.1/config/supervisord.conf @@ -15,3 +15,10 @@ stdout_logfile = /dev/stdout stdout_logfile_maxbytes = 0 stderr_logfile = /dev/stderr stderr_logfile_maxbytes = 0 + +[program:cron] +command = /usr/sbin/cron +stdout_logfile = /dev/stdout +stdout_logfile_maxbytes = 0 +stderr_logfile = /dev/stderr +stderr_logfile_maxbytes = 0 diff --git a/7.1/startup.sh b/7.1/startup.sh index 97bfbaa4..79b7cb84 100755 --- a/7.1/startup.sh +++ b/7.1/startup.sh @@ -97,6 +97,11 @@ chown "${HOST_UID-:1000}:${HOST_GID:-1000}" /var/www echo-debug "Preliminary initialization completed" touch /var/run/cli +# If crontab file is found within project add contents to user crontab file. +if [[ -f ${PROJECT_ROOT}/.docksal/services/cli/crontab ]]; then + cat ${PROJECT_ROOT}/.docksal/services/cli/crontab | crontab -u docker - +fi + if [[ -x ${PROJECT_ROOT}/.docksal/services/cli/startup.sh ]]; then echo-debug "Running Custom Startup Script..." ${PROJECT_ROOT}/.docksal/services/cli/startup.sh diff --git a/7.2/config/supervisord.conf b/7.2/config/supervisord.conf index 1ae1f475..574eeff5 100644 --- a/7.2/config/supervisord.conf +++ b/7.2/config/supervisord.conf @@ -15,3 +15,10 @@ stdout_logfile = /dev/stdout stdout_logfile_maxbytes = 0 stderr_logfile = /dev/stderr stderr_logfile_maxbytes = 0 + +[program:cron] +command = /usr/sbin/cron +stdout_logfile = /dev/stdout +stdout_logfile_maxbytes = 0 +stderr_logfile = /dev/stderr +stderr_logfile_maxbytes = 0 diff --git a/7.2/startup.sh b/7.2/startup.sh index 97bfbaa4..79b7cb84 100755 --- a/7.2/startup.sh +++ b/7.2/startup.sh @@ -97,6 +97,11 @@ chown "${HOST_UID-:1000}:${HOST_GID:-1000}" /var/www echo-debug "Preliminary initialization completed" touch /var/run/cli +# If crontab file is found within project add contents to user crontab file. +if [[ -f ${PROJECT_ROOT}/.docksal/services/cli/crontab ]]; then + cat ${PROJECT_ROOT}/.docksal/services/cli/crontab | crontab -u docker - +fi + if [[ -x ${PROJECT_ROOT}/.docksal/services/cli/startup.sh ]]; then echo-debug "Running Custom Startup Script..." ${PROJECT_ROOT}/.docksal/services/cli/startup.sh diff --git a/README.md b/README.md index 40179dda..0f2a17cb 100644 --- a/README.md +++ b/README.md @@ -41,6 +41,7 @@ This image(s) is part of the [Docksal](http://docksal.io) image library. - nodejs - npm, yarn - python +- cron Other notable tools: @@ -84,6 +85,11 @@ To run a custom startup script anytime the `cli` container has started create a `.docksal/services/cli` directory. Additionally, make sure that the file is executable as well so that the container does not run into issues when attempting to execute the file. +## Customized Cron Configuration + +Cron can be configured by making sure there is a `crontab` file located within `.docksal/services/cli`. The file should +be filled out accordingly such that it follows the standard crontab format. For more information click [here](http://www.nncron.ru/help/EN/working/cron-format.htm). + ## Secrets and integrations `cli` can read secrets from environment variables and configure the respective integrations automatically at start. diff --git a/tests/.docksal/services/cli/crontab b/tests/.docksal/services/cli/crontab new file mode 100644 index 00000000..82d24cee --- /dev/null +++ b/tests/.docksal/services/cli/crontab @@ -0,0 +1 @@ +* * * * * echo "The current date is $(date)" > /tmp/date.txt diff --git a/tests/test.bats b/tests/test.bats index 63982e52..5a69d9f2 100755 --- a/tests/test.bats +++ b/tests/test.bats @@ -340,3 +340,42 @@ _healthcheck_wait () ### Cleanup ### docker rm -vf "$NAME" >/dev/null 2>&1 || true } + +@test "Custom Cron Integration" { + [[ $SKIP == 1 ]] && skip + + ### Setup ### + docker rm -vf "$NAME" >/dev/null 2>&1 || true + docker run --name "$NAME" -d \ + -v /home/docker \ + -v $(pwd)/../tests:/var/www \ + "$IMAGE" + _healthcheck_wait + + ### Tests ### + # Confirm output from cron is working + + # Create tmp date file + docker exec -it -u docker "$NAME" bash -c 'echo "The current date is $(date)" > /tmp/date.txt; chmod 0777 /tmp/date.txt' + + # Confirm File created and exists + run docker exec -it -u docker "$NAME" bash -c 'cat /tmp/date.txt' + [[ "${output}" =~ "The current date is " ]] + OLD_OUTPUT="${output}" + unset output + + # Sleep for 60 Seconds so cron can run again. + sleep 60 + + # Confirm cron has ran and file contents has changed + run docker exec -it -u docker "$NAME" bash -c 'cat /tmp/date.txt' + [[ "${output}" =~ "The current date is " ]] + NEW_OUTPUT="${output}" + unset output + + # Confirm First Test is not the same as old test + [[ "${OLD_OUTPUT}" != "${NEW_OUTPUT}" ]] + + ### Cleanup ### + docker rm -vf "$NAME" >/dev/null 2>&1 || true +} From bcd68e0ca6881e3e31c0af321579c75e70da2862 Mon Sep 17 00:00:00 2001 From: Shelane French Date: Tue, 3 Jul 2018 10:19:35 -0700 Subject: [PATCH 20/45] Updated README readability and link accessibility (#65) --- README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 0f2a17cb..64c18bb6 100644 --- a/README.md +++ b/README.md @@ -77,18 +77,18 @@ cli ... ``` -See [docs](https://docs.docksal.io/en/master/tools/xdebug) on using Xdebug for web and cli PHP debugging. +[See docs](https://docs.docksal.io/en/master/tools/xdebug) on using Xdebug for web and cli PHP debugging. ## Customizing Startup -To run a custom startup script anytime the `cli` container has started create a `startup.sh` file within the +To run a custom startup script anytime the `cli` container has started, create a `startup.sh` file within the `.docksal/services/cli` directory. Additionally, make sure that the file is executable as well so that the container does not run into issues when attempting to execute the file. ## Customized Cron Configuration Cron can be configured by making sure there is a `crontab` file located within `.docksal/services/cli`. The file should -be filled out accordingly such that it follows the standard crontab format. For more information click [here](http://www.nncron.ru/help/EN/working/cron-format.htm). +follow the [standard crontab format](http://www.nncron.ru/help/EN/working/cron-format.htm). ## Secrets and integrations From ccbac21b4dd7dda34f5798430d973179e0c871f9 Mon Sep 17 00:00:00 2001 From: Leonid Makarov Date: Fri, 6 Jul 2018 14:51:11 -0700 Subject: [PATCH 21/45] Moved things around - Moved gomplate up to global tool section next to gosu (added GOSU_VERSION variable) - Moved platformsh CLI up to other phar based installs --- 5.6/Dockerfile | 35 ++++++++++++++++++----------------- 7.0/Dockerfile | 35 ++++++++++++++++++----------------- 7.1/Dockerfile | 35 ++++++++++++++++++----------------- 7.2/Dockerfile | 35 ++++++++++++++++++----------------- 4 files changed, 72 insertions(+), 68 deletions(-) diff --git a/5.6/Dockerfile b/5.6/Dockerfile index a4df69ba..10542070 100644 --- a/5.6/Dockerfile +++ b/5.6/Dockerfile @@ -91,13 +91,18 @@ RUN set -xe; \ useradd -m -s /bin/bash -u 1000 -g 1000 -G sudo -p docker docker; \ echo 'docker ALL=(ALL) NOPASSWD:ALL' >> /etc/sudoers -# Install gosu and give access to the docker user primary group to use it. -# gosu is used instead of sudo to start the main container process (pid 1) in a docker friendly way. -# https://github.com/tianon/gosu +ENV GOSU_VERSION=1.10 \ + GOMPLATE_VERSION=2.4.0 RUN set -xe; \ - curl -sSL "https://github.com/tianon/gosu/releases/download/1.10/gosu-$(dpkg --print-architecture)" -o /usr/local/bin/gosu; \ + # Install gosu and give access to the docker user primary group to use it. + # gosu is used instead of sudo to start the main container process (pid 1) in a docker friendly way. + # https://github.com/tianon/gosu + curl -sSL "https://github.com/tianon/gosu/releases/download/${GOSU_VERSION}/gosu-$(dpkg --print-architecture)" -o /usr/local/bin/gosu; \ chown root:"$(id -gn docker)" /usr/local/bin/gosu; \ - chmod +sx /usr/local/bin/gosu + chmod +sx /usr/local/bin/gosu; \ + # gomplate (to process configuration templates in startup.sh) + curl -sSL https://github.com/hairyhenderson/gomplate/releases/download/v${GOMPLATE_VERSION}/gomplate_linux-amd64-slim -o /usr/local/bin/gomplate; \ + chmod +x /usr/local/bin/gomplate # Configure sshd (for use PHPStorm's remote interpreters and tools integrations) # http://docs.docker.com/examples/running_ssh_service/ @@ -213,11 +218,12 @@ RUN set -xe; \ ENV COMPOSER_VERSION=1.6.3 \ DRUSH_VERSION=8.1.16 \ DRUSH_LAUNCHER_VERSION=0.6.0 \ + DRUSH_LAUNCHER_FALLBACK=/usr/local/bin/drush8 \ DRUPAL_CONSOLE_VERSION=1.7.0 \ WPCLI_VERSION=1.5.0 \ MG_CODEGEN_VERSION=1.10 \ BLACKFIRE_VERSION=1.15.0 \ - GOMPLATE_VERSION=2.4.0 + PLATFORMSH_CLI_VERSION=3.33.5 RUN set -xe; \ # Composer curl -sSL "https://github.com/composer/composer/releases/download/${COMPOSER_VERSION}/composer.phar" -o /usr/local/bin/composer; \ @@ -232,11 +238,11 @@ RUN set -xe; \ # Magento2 Code Generator curl -sSL "https://github.com/staempfli/magento2-code-generator/releases/download/${MG_CODEGEN_VERSION}/mg2-codegen.phar" -o /usr/local/bin/mg2-codegen; \ # Blackfire CLI - curl -sSL https://packages.blackfire.io/binaries/blackfire-agent/${BLACKFIRE_VERSION}/blackfire-cli-linux_static_amd64 -o /usr/local/bin/blackfire; \ - # gomplate - curl -sSL https://github.com/hairyhenderson/gomplate/releases/download/v${GOMPLATE_VERSION}/gomplate_linux-amd64-slim -o /usr/local/bin/gomplate; \ - # Make all binaries executable in one shot - cd /usr/local/bin && chmod +x composer drush8 drush drupal wp mg2-codegen blackfire gomplate; + curl -sSL "https://packages.blackfire.io/binaries/blackfire-agent/${BLACKFIRE_VERSION}/blackfire-cli-linux_static_amd64" -o /usr/local/bin/blackfire; \ + # Platform.sh CLI + curl -sSL "https://github.com/platformsh/platformsh-cli/releases/download/v${PLATFORMSH_CLI_VERSION}/platform.phar" -o /usr/local/bin/platform; \ + # Make all downloaded binaries executable in one shot + (cd /usr/local/bin && chmod +x composer drush8 drush drupal wp mg2-codegen blackfire platform); # Node.js ENV NODE_VERSION=8.x @@ -272,12 +278,9 @@ USER docker ENV HOME /home/docker # Install Composer based dependencies -ENV PATH=$PATH:$HOME/.composer/vendor/bin \ - DRUSH_LAUNCHER_FALLBACK=/usr/local/bin/drush8 +ENV PATH=$PATH:$HOME/.composer/vendor/bin ENV PATH=$PATH:$HOME/.terminus/vendor/bin \ TERMINUS_VERSION=1.8.1 -ENV PATH=$PATH:$HOME/.platformsh \ - PLATFORMSH_CLI_VERSION=3.33.5 RUN set -xe; \ # Add composer bin directory to PATH echo "\n"'PATH="$PATH:$HOME/.composer/vendor/bin"' >> $HOME/.profile; \ @@ -295,8 +298,6 @@ RUN set -xe; \ mkdir -p $HOME/.terminus; \ # Run in a subshell since we are doing directory switching (cd $HOME/.terminus && composer require pantheon-systems/terminus:${TERMINUS_VERSION}); \ - mkdir -p $HOME/.platformsh; \ - (cd $HOME/.platformsh && curl -o platform -L "https://github.com/platformsh/platformsh-cli/releases/download/v${PLATFORMSH_CLI_VERSION}/platform.phar" && chmod 755 platform); \ # Cleanup composer clear-cache diff --git a/7.0/Dockerfile b/7.0/Dockerfile index 5e5acc05..457b30c7 100644 --- a/7.0/Dockerfile +++ b/7.0/Dockerfile @@ -94,13 +94,18 @@ RUN set -xe; \ useradd -m -s /bin/bash -u 1000 -g 1000 -G sudo -p docker docker; \ echo 'docker ALL=(ALL) NOPASSWD:ALL' >> /etc/sudoers -# Install gosu and give access to the docker user primary group to use it. -# gosu is used instead of sudo to start the main container process (pid 1) in a docker friendly way. -# https://github.com/tianon/gosu +ENV GOSU_VERSION=1.10 \ + GOMPLATE_VERSION=2.4.0 RUN set -xe; \ - curl -sSL "https://github.com/tianon/gosu/releases/download/1.10/gosu-$(dpkg --print-architecture)" -o /usr/local/bin/gosu; \ + # Install gosu and give access to the docker user primary group to use it. + # gosu is used instead of sudo to start the main container process (pid 1) in a docker friendly way. + # https://github.com/tianon/gosu + curl -sSL "https://github.com/tianon/gosu/releases/download/${GOSU_VERSION}/gosu-$(dpkg --print-architecture)" -o /usr/local/bin/gosu; \ chown root:"$(id -gn docker)" /usr/local/bin/gosu; \ - chmod +sx /usr/local/bin/gosu + chmod +sx /usr/local/bin/gosu; \ + # gomplate (to process configuration templates in startup.sh) + curl -sSL https://github.com/hairyhenderson/gomplate/releases/download/v${GOMPLATE_VERSION}/gomplate_linux-amd64-slim -o /usr/local/bin/gomplate; \ + chmod +x /usr/local/bin/gomplate # Configure sshd (for use PHPStorm's remote interpreters and tools integrations) # http://docs.docker.com/examples/running_ssh_service/ @@ -222,11 +227,12 @@ RUN set -xe; \ ENV COMPOSER_VERSION=1.6.3 \ DRUSH_VERSION=8.1.16 \ DRUSH_LAUNCHER_VERSION=0.6.0 \ + DRUSH_LAUNCHER_FALLBACK=/usr/local/bin/drush8 \ DRUPAL_CONSOLE_VERSION=1.7.0 \ WPCLI_VERSION=1.5.0 \ MG_CODEGEN_VERSION=1.10 \ BLACKFIRE_VERSION=1.15.0 \ - GOMPLATE_VERSION=2.4.0 + PLATFORMSH_CLI_VERSION=3.33.5 RUN set -xe; \ # Composer curl -sSL "https://github.com/composer/composer/releases/download/${COMPOSER_VERSION}/composer.phar" -o /usr/local/bin/composer; \ @@ -241,11 +247,11 @@ RUN set -xe; \ # Magento2 Code Generator curl -sSL "https://github.com/staempfli/magento2-code-generator/releases/download/${MG_CODEGEN_VERSION}/mg2-codegen.phar" -o /usr/local/bin/mg2-codegen; \ # Blackfire CLI - curl -sSL https://packages.blackfire.io/binaries/blackfire-agent/${BLACKFIRE_VERSION}/blackfire-cli-linux_static_amd64 -o /usr/local/bin/blackfire; \ - # gomplate - curl -sSL https://github.com/hairyhenderson/gomplate/releases/download/v${GOMPLATE_VERSION}/gomplate_linux-amd64-slim -o /usr/local/bin/gomplate; \ - # Make all binaries executable in one shot - cd /usr/local/bin && chmod +x composer drush8 drush drupal wp mg2-codegen blackfire gomplate; + curl -sSL "https://packages.blackfire.io/binaries/blackfire-agent/${BLACKFIRE_VERSION}/blackfire-cli-linux_static_amd64" -o /usr/local/bin/blackfire; \ + # Platform.sh CLI + curl -sSL "https://github.com/platformsh/platformsh-cli/releases/download/v${PLATFORMSH_CLI_VERSION}/platform.phar" -o /usr/local/bin/platform; \ + # Make all downloaded binaries executable in one shot + (cd /usr/local/bin && chmod +x composer drush8 drush drupal wp mg2-codegen blackfire platform); # Node.js ENV NODE_VERSION=8.x @@ -281,12 +287,9 @@ USER docker ENV HOME /home/docker # Install Composer based dependencies -ENV PATH=$PATH:$HOME/.composer/vendor/bin \ - DRUSH_LAUNCHER_FALLBACK=/usr/local/bin/drush8 +ENV PATH=$PATH:$HOME/.composer/vendor/bin ENV PATH=$PATH:$HOME/.terminus/vendor/bin \ TERMINUS_VERSION=1.8.1 -ENV PATH=$PATH:$HOME/.platformsh \ - PLATFORMSH_CLI_VERSION=3.33.5 RUN set -xe; \ # Add composer bin directory to PATH echo "\n"'PATH="$PATH:$HOME/.composer/vendor/bin"' >> $HOME/.profile; \ @@ -304,8 +307,6 @@ RUN set -xe; \ mkdir -p $HOME/.terminus; \ # Run in a subshell since we are doing directory switching (cd $HOME/.terminus && composer require pantheon-systems/terminus:${TERMINUS_VERSION}); \ - mkdir -p $HOME/.platformsh; \ - (cd $HOME/.platformsh && curl -o platform -L "https://github.com/platformsh/platformsh-cli/releases/download/v${PLATFORMSH_CLI_VERSION}/platform.phar" && chmod 755 platform); \ # Cleanup composer clear-cache diff --git a/7.1/Dockerfile b/7.1/Dockerfile index db9e911b..ff61b975 100644 --- a/7.1/Dockerfile +++ b/7.1/Dockerfile @@ -94,13 +94,18 @@ RUN set -xe; \ useradd -m -s /bin/bash -u 1000 -g 1000 -G sudo -p docker docker; \ echo 'docker ALL=(ALL) NOPASSWD:ALL' >> /etc/sudoers -# Install gosu and give access to the docker user primary group to use it. -# gosu is used instead of sudo to start the main container process (pid 1) in a docker friendly way. -# https://github.com/tianon/gosu +ENV GOSU_VERSION=1.10 \ + GOMPLATE_VERSION=2.4.0 RUN set -xe; \ - curl -sSL "https://github.com/tianon/gosu/releases/download/1.10/gosu-$(dpkg --print-architecture)" -o /usr/local/bin/gosu; \ + # Install gosu and give access to the docker user primary group to use it. + # gosu is used instead of sudo to start the main container process (pid 1) in a docker friendly way. + # https://github.com/tianon/gosu + curl -sSL "https://github.com/tianon/gosu/releases/download/${GOSU_VERSION}/gosu-$(dpkg --print-architecture)" -o /usr/local/bin/gosu; \ chown root:"$(id -gn docker)" /usr/local/bin/gosu; \ - chmod +sx /usr/local/bin/gosu + chmod +sx /usr/local/bin/gosu; \ + # gomplate (to process configuration templates in startup.sh) + curl -sSL https://github.com/hairyhenderson/gomplate/releases/download/v${GOMPLATE_VERSION}/gomplate_linux-amd64-slim -o /usr/local/bin/gomplate; \ + chmod +x /usr/local/bin/gomplate # Configure sshd (for use PHPStorm's remote interpreters and tools integrations) # http://docs.docker.com/examples/running_ssh_service/ @@ -222,11 +227,12 @@ RUN set -xe; \ ENV COMPOSER_VERSION=1.6.3 \ DRUSH_VERSION=8.1.16 \ DRUSH_LAUNCHER_VERSION=0.6.0 \ + DRUSH_LAUNCHER_FALLBACK=/usr/local/bin/drush8 \ DRUPAL_CONSOLE_VERSION=1.7.0 \ WPCLI_VERSION=1.5.0 \ MG_CODEGEN_VERSION=1.10 \ BLACKFIRE_VERSION=1.15.0 \ - GOMPLATE_VERSION=2.4.0 + PLATFORMSH_CLI_VERSION=3.33.5 RUN set -xe; \ # Composer curl -sSL "https://github.com/composer/composer/releases/download/${COMPOSER_VERSION}/composer.phar" -o /usr/local/bin/composer; \ @@ -241,11 +247,11 @@ RUN set -xe; \ # Magento2 Code Generator curl -sSL "https://github.com/staempfli/magento2-code-generator/releases/download/${MG_CODEGEN_VERSION}/mg2-codegen.phar" -o /usr/local/bin/mg2-codegen; \ # Blackfire CLI - curl -sSL https://packages.blackfire.io/binaries/blackfire-agent/${BLACKFIRE_VERSION}/blackfire-cli-linux_static_amd64 -o /usr/local/bin/blackfire; \ - # gomplate - curl -sSL https://github.com/hairyhenderson/gomplate/releases/download/v${GOMPLATE_VERSION}/gomplate_linux-amd64-slim -o /usr/local/bin/gomplate; \ - # Make all binaries executable in one shot - cd /usr/local/bin && chmod +x composer drush8 drush drupal wp mg2-codegen blackfire gomplate; + curl -sSL "https://packages.blackfire.io/binaries/blackfire-agent/${BLACKFIRE_VERSION}/blackfire-cli-linux_static_amd64" -o /usr/local/bin/blackfire; \ + # Platform.sh CLI + curl -sSL "https://github.com/platformsh/platformsh-cli/releases/download/v${PLATFORMSH_CLI_VERSION}/platform.phar" -o /usr/local/bin/platform; \ + # Make all downloaded binaries executable in one shot + (cd /usr/local/bin && chmod +x composer drush8 drush drupal wp mg2-codegen blackfire platform); # Node.js ENV NODE_VERSION=8.x @@ -281,12 +287,9 @@ USER docker ENV HOME /home/docker # Install Composer based dependencies -ENV PATH=$PATH:$HOME/.composer/vendor/bin \ - DRUSH_LAUNCHER_FALLBACK=/usr/local/bin/drush8 +ENV PATH=$PATH:$HOME/.composer/vendor/bin ENV PATH=$PATH:$HOME/.terminus/vendor/bin \ TERMINUS_VERSION=1.8.1 -ENV PATH=$PATH:$HOME/.platformsh \ - PLATFORMSH_CLI_VERSION=3.33.5 RUN set -xe; \ # Add composer bin directory to PATH echo "\n"'PATH="$PATH:$HOME/.composer/vendor/bin"' >> $HOME/.profile; \ @@ -304,8 +307,6 @@ RUN set -xe; \ mkdir -p $HOME/.terminus; \ # Run in a subshell since we are doing directory switching (cd $HOME/.terminus && composer require pantheon-systems/terminus:${TERMINUS_VERSION}); \ - mkdir -p $HOME/.platformsh; \ - (cd $HOME/.platformsh && curl -o platform -L "https://github.com/platformsh/platformsh-cli/releases/download/v${PLATFORMSH_CLI_VERSION}/platform.phar" && chmod 755 platform); \ # Cleanup composer clear-cache diff --git a/7.2/Dockerfile b/7.2/Dockerfile index 734856b6..da14899e 100644 --- a/7.2/Dockerfile +++ b/7.2/Dockerfile @@ -94,13 +94,18 @@ RUN set -xe; \ useradd -m -s /bin/bash -u 1000 -g 1000 -G sudo -p docker docker; \ echo 'docker ALL=(ALL) NOPASSWD:ALL' >> /etc/sudoers -# Install gosu and give access to the docker user primary group to use it. -# gosu is used instead of sudo to start the main container process (pid 1) in a docker friendly way. -# https://github.com/tianon/gosu +ENV GOSU_VERSION=1.10 \ + GOMPLATE_VERSION=2.4.0 RUN set -xe; \ - curl -sSL "https://github.com/tianon/gosu/releases/download/1.10/gosu-$(dpkg --print-architecture)" -o /usr/local/bin/gosu; \ + # Install gosu and give access to the docker user primary group to use it. + # gosu is used instead of sudo to start the main container process (pid 1) in a docker friendly way. + # https://github.com/tianon/gosu + curl -sSL "https://github.com/tianon/gosu/releases/download/${GOSU_VERSION}/gosu-$(dpkg --print-architecture)" -o /usr/local/bin/gosu; \ chown root:"$(id -gn docker)" /usr/local/bin/gosu; \ - chmod +sx /usr/local/bin/gosu + chmod +sx /usr/local/bin/gosu; \ + # gomplate (to process configuration templates in startup.sh) + curl -sSL https://github.com/hairyhenderson/gomplate/releases/download/v${GOMPLATE_VERSION}/gomplate_linux-amd64-slim -o /usr/local/bin/gomplate; \ + chmod +x /usr/local/bin/gomplate # Configure sshd (for use PHPStorm's remote interpreters and tools integrations) # http://docs.docker.com/examples/running_ssh_service/ @@ -224,11 +229,12 @@ RUN set -xe; \ ENV COMPOSER_VERSION=1.6.3 \ DRUSH_VERSION=8.1.16 \ DRUSH_LAUNCHER_VERSION=0.6.0 \ + DRUSH_LAUNCHER_FALLBACK=/usr/local/bin/drush8 \ DRUPAL_CONSOLE_VERSION=1.7.0 \ WPCLI_VERSION=1.5.0 \ MG_CODEGEN_VERSION=1.10 \ BLACKFIRE_VERSION=1.15.0 \ - GOMPLATE_VERSION=2.4.0 + PLATFORMSH_CLI_VERSION=3.33.5 RUN set -xe; \ # Composer curl -sSL "https://github.com/composer/composer/releases/download/${COMPOSER_VERSION}/composer.phar" -o /usr/local/bin/composer; \ @@ -243,11 +249,11 @@ RUN set -xe; \ # Magento2 Code Generator curl -sSL "https://github.com/staempfli/magento2-code-generator/releases/download/${MG_CODEGEN_VERSION}/mg2-codegen.phar" -o /usr/local/bin/mg2-codegen; \ # Blackfire CLI - curl -sSL https://packages.blackfire.io/binaries/blackfire-agent/${BLACKFIRE_VERSION}/blackfire-cli-linux_static_amd64 -o /usr/local/bin/blackfire; \ - # gomplate - curl -sSL https://github.com/hairyhenderson/gomplate/releases/download/v${GOMPLATE_VERSION}/gomplate_linux-amd64-slim -o /usr/local/bin/gomplate; \ - # Make all binaries executable in one shot - cd /usr/local/bin && chmod +x composer drush8 drush drupal wp mg2-codegen blackfire gomplate; + curl -sSL "https://packages.blackfire.io/binaries/blackfire-agent/${BLACKFIRE_VERSION}/blackfire-cli-linux_static_amd64" -o /usr/local/bin/blackfire; \ + # Platform.sh CLI + curl -sSL "https://github.com/platformsh/platformsh-cli/releases/download/v${PLATFORMSH_CLI_VERSION}/platform.phar" -o /usr/local/bin/platform; \ + # Make all downloaded binaries executable in one shot + (cd /usr/local/bin && chmod +x composer drush8 drush drupal wp mg2-codegen blackfire platform); # Node.js ENV NODE_VERSION=8.x @@ -283,12 +289,9 @@ USER docker ENV HOME /home/docker # Install Composer based dependencies -ENV PATH=$PATH:$HOME/.composer/vendor/bin \ - DRUSH_LAUNCHER_FALLBACK=/usr/local/bin/drush8 +ENV PATH=$PATH:$HOME/.composer/vendor/bin ENV PATH=$PATH:$HOME/.terminus/vendor/bin \ TERMINUS_VERSION=1.8.1 -ENV PATH=$PATH:$HOME/.platformsh \ - PLATFORMSH_CLI_VERSION=3.33.5 RUN set -xe; \ # Add composer bin directory to PATH echo "\n"'PATH="$PATH:$HOME/.composer/vendor/bin"' >> $HOME/.profile; \ @@ -306,8 +309,6 @@ RUN set -xe; \ mkdir -p $HOME/.terminus; \ # Run in a subshell since we are doing directory switching (cd $HOME/.terminus && composer require pantheon-systems/terminus:${TERMINUS_VERSION}); \ - mkdir -p $HOME/.platformsh; \ - (cd $HOME/.platformsh && curl -o platform -L "https://github.com/platformsh/platformsh-cli/releases/download/v${PLATFORMSH_CLI_VERSION}/platform.phar" && chmod 755 platform); \ # Cleanup composer clear-cache From 95e59f18c174fe8d21084965c319418b0a257feb Mon Sep 17 00:00:00 2001 From: Leonid Makarov Date: Fri, 6 Jul 2018 15:41:23 -0700 Subject: [PATCH 22/45] Use curl -fsSL for downloads -f - fail if HTTP return code is not 200 -sS - silent mode, but show error messages if failed -L - follow HTTP redirects --- 5.6/Dockerfile | 28 ++++++++++++++-------------- 7.0/Dockerfile | 30 +++++++++++++++--------------- 7.1/Dockerfile | 30 +++++++++++++++--------------- 7.2/Dockerfile | 30 +++++++++++++++--------------- 4 files changed, 59 insertions(+), 59 deletions(-) diff --git a/5.6/Dockerfile b/5.6/Dockerfile index 10542070..c2263d86 100644 --- a/5.6/Dockerfile +++ b/5.6/Dockerfile @@ -42,10 +42,10 @@ RUN set -xe; \ # backports repo echo "deb http://ftp.debian.org/debian jessie-backports main" | tee /etc/apt/sources.list.d/backports.list; \ # blackfire.io repo - curl -sSL https://packagecloud.io/gpg.key | apt-key add -; \ + curl -fssL https://packagecloud.io/gpg.key | apt-key add -; \ echo "deb https://packages.blackfire.io/debian any main" | tee /etc/apt/sources.list.d/blackfire.list; \ # git-lfs repo - curl -sSL https://packagecloud.io/github/git-lfs/gpgkey | apt-key add -; \ + curl -fsSL https://packagecloud.io/github/git-lfs/gpgkey | apt-key add -; \ echo 'deb https://packagecloud.io/github/git-lfs/debian/ jessie main' | tee /etc/apt/sources.list.d/github_git-lfs.list; \ echo 'deb-src https://packagecloud.io/github/git-lfs/debian/ jessie main' | tee -a /etc/apt/sources.list.d/github_git-lfs.list; @@ -97,11 +97,11 @@ RUN set -xe; \ # Install gosu and give access to the docker user primary group to use it. # gosu is used instead of sudo to start the main container process (pid 1) in a docker friendly way. # https://github.com/tianon/gosu - curl -sSL "https://github.com/tianon/gosu/releases/download/${GOSU_VERSION}/gosu-$(dpkg --print-architecture)" -o /usr/local/bin/gosu; \ + curl -fsSL "https://github.com/tianon/gosu/releases/download/${GOSU_VERSION}/gosu-$(dpkg --print-architecture)" -o /usr/local/bin/gosu; \ chown root:"$(id -gn docker)" /usr/local/bin/gosu; \ chmod +sx /usr/local/bin/gosu; \ # gomplate (to process configuration templates in startup.sh) - curl -sSL https://github.com/hairyhenderson/gomplate/releases/download/v${GOMPLATE_VERSION}/gomplate_linux-amd64-slim -o /usr/local/bin/gomplate; \ + curl -fsSL https://github.com/hairyhenderson/gomplate/releases/download/v${GOMPLATE_VERSION}/gomplate_linux-amd64-slim -o /usr/local/bin/gomplate; \ chmod +x /usr/local/bin/gomplate # Configure sshd (for use PHPStorm's remote interpreters and tools integrations) @@ -226,21 +226,21 @@ ENV COMPOSER_VERSION=1.6.3 \ PLATFORMSH_CLI_VERSION=3.33.5 RUN set -xe; \ # Composer - curl -sSL "https://github.com/composer/composer/releases/download/${COMPOSER_VERSION}/composer.phar" -o /usr/local/bin/composer; \ + curl -fsSL "https://github.com/composer/composer/releases/download/${COMPOSER_VERSION}/composer.phar" -o /usr/local/bin/composer; \ # Drush 8 (default) - curl -sSL "https://github.com/drush-ops/drush/releases/download/${DRUSH_VERSION}/drush.phar" -o /usr/local/bin/drush8; \ + curl -fsSL "https://github.com/drush-ops/drush/releases/download/${DRUSH_VERSION}/drush.phar" -o /usr/local/bin/drush8; \ # Drush Launcher - curl -sSL "https://github.com/drush-ops/drush-launcher/releases/download/${DRUSH_LAUNCHER_VERSION}/drush.phar" -o /usr/local/bin/drush; \ + curl -fsSL "https://github.com/drush-ops/drush-launcher/releases/download/${DRUSH_LAUNCHER_VERSION}/drush.phar" -o /usr/local/bin/drush; \ # Drupal Console - curl -sSL "https://github.com/hechoendrupal/drupal-console-launcher/releases/download/${DRUPAL_CONSOLE_VERSION}/drupal.phar" -o /usr/local/bin/drupal; \ + curl -fsSL "https://github.com/hechoendrupal/drupal-console-launcher/releases/download/${DRUPAL_CONSOLE_VERSION}/drupal.phar" -o /usr/local/bin/drupal; \ # Wordpress CLI - curl -sSL "https://github.com/wp-cli/wp-cli/releases/download/v${WPCLI_VERSION}/wp-cli-${WPCLI_VERSION}.phar" -o /usr/local/bin/wp; \ + curl -fsSL "https://github.com/wp-cli/wp-cli/releases/download/v${WPCLI_VERSION}/wp-cli-${WPCLI_VERSION}.phar" -o /usr/local/bin/wp; \ # Magento2 Code Generator - curl -sSL "https://github.com/staempfli/magento2-code-generator/releases/download/${MG_CODEGEN_VERSION}/mg2-codegen.phar" -o /usr/local/bin/mg2-codegen; \ + curl -fsSL "https://github.com/staempfli/magento2-code-generator/releases/download/${MG_CODEGEN_VERSION}/mg2-codegen.phar" -o /usr/local/bin/mg2-codegen; \ # Blackfire CLI - curl -sSL "https://packages.blackfire.io/binaries/blackfire-agent/${BLACKFIRE_VERSION}/blackfire-cli-linux_static_amd64" -o /usr/local/bin/blackfire; \ + curl -fsSL "https://packages.blackfire.io/binaries/blackfire-agent/${BLACKFIRE_VERSION}/blackfire-cli-linux_static_amd64" -o /usr/local/bin/blackfire; \ # Platform.sh CLI - curl -sSL "https://github.com/platformsh/platformsh-cli/releases/download/v${PLATFORMSH_CLI_VERSION}/platform.phar" -o /usr/local/bin/platform; \ + curl -fsSL "https://github.com/platformsh/platformsh-cli/releases/download/v${PLATFORMSH_CLI_VERSION}/platform.phar" -o /usr/local/bin/platform; \ # Make all downloaded binaries executable in one shot (cd /usr/local/bin && chmod +x composer drush8 drush drupal wp mg2-codegen blackfire platform); @@ -248,11 +248,11 @@ RUN set -xe; \ ENV NODE_VERSION=8.x RUN set -xe; \ # Node.js repo - curl -sSL https://deb.nodesource.com/gpgkey/nodesource.gpg.key | apt-key add -; \ + curl -fsSL https://deb.nodesource.com/gpgkey/nodesource.gpg.key | apt-key add -; \ echo "deb https://deb.nodesource.com/node_${NODE_VERSION} jessie main" | sudo tee /etc/apt/sources.list.d/nodesource.list; \ echo "deb-src https://deb.nodesource.com/node_${NODE_VERSION} jessie main" | sudo tee -a /etc/apt/sources.list.d/nodesource.list; \ # yarn repo - curl -sSL https://dl.yarnpkg.com/debian/pubkey.gpg | apt-key add -; \ + curl -fsSL https://dl.yarnpkg.com/debian/pubkey.gpg | apt-key add -; \ echo "deb https://dl.yarnpkg.com/debian/ stable main" | tee /etc/apt/sources.list.d/yarn.list; \ apt-get update >/dev/null; apt-get -y --force-yes --no-install-recommends install >/dev/null \ nodejs \ diff --git a/7.0/Dockerfile b/7.0/Dockerfile index 457b30c7..2e53db13 100644 --- a/7.0/Dockerfile +++ b/7.0/Dockerfile @@ -42,14 +42,14 @@ RUN set -xe; \ # backports repo echo "deb http://ftp.debian.org/debian jessie-backports main" | tee /etc/apt/sources.list.d/backports.list; \ # blackfire.io repo - curl -sSL https://packagecloud.io/gpg.key | apt-key add -; \ + curl -fsSL https://packagecloud.io/gpg.key | apt-key add -; \ echo "deb https://packages.blackfire.io/debian any main" | tee /etc/apt/sources.list.d/blackfire.list; \ # git-lfs repo - curl -sSL https://packagecloud.io/github/git-lfs/gpgkey | apt-key add -; \ + curl -fsSL https://packagecloud.io/github/git-lfs/gpgkey | apt-key add -; \ echo 'deb https://packagecloud.io/github/git-lfs/debian/ jessie main' | tee /etc/apt/sources.list.d/github_git-lfs.list; \ echo 'deb-src https://packagecloud.io/github/git-lfs/debian/ jessie main' | tee -a /etc/apt/sources.list.d/github_git-lfs.list; \ # MSQSQL repo - msodbcsql17, pecl/sqlsrv and pecl/pdo_sqlsrv (PHP 7.0+ only) - curl -sSL https://packages.microsoft.com/keys/microsoft.asc | apt-key add -; \ + curl -fsSL https://packages.microsoft.com/keys/microsoft.asc | apt-key add -; \ echo 'deb https://packages.microsoft.com/debian/8/prod jessie main' | tee /etc/apt/sources.list.d/mssql.list; # Additional packages @@ -100,11 +100,11 @@ RUN set -xe; \ # Install gosu and give access to the docker user primary group to use it. # gosu is used instead of sudo to start the main container process (pid 1) in a docker friendly way. # https://github.com/tianon/gosu - curl -sSL "https://github.com/tianon/gosu/releases/download/${GOSU_VERSION}/gosu-$(dpkg --print-architecture)" -o /usr/local/bin/gosu; \ + curl -fsSL "https://github.com/tianon/gosu/releases/download/${GOSU_VERSION}/gosu-$(dpkg --print-architecture)" -o /usr/local/bin/gosu; \ chown root:"$(id -gn docker)" /usr/local/bin/gosu; \ chmod +sx /usr/local/bin/gosu; \ # gomplate (to process configuration templates in startup.sh) - curl -sSL https://github.com/hairyhenderson/gomplate/releases/download/v${GOMPLATE_VERSION}/gomplate_linux-amd64-slim -o /usr/local/bin/gomplate; \ + curl -fsSL https://github.com/hairyhenderson/gomplate/releases/download/v${GOMPLATE_VERSION}/gomplate_linux-amd64-slim -o /usr/local/bin/gomplate; \ chmod +x /usr/local/bin/gomplate # Configure sshd (for use PHPStorm's remote interpreters and tools integrations) @@ -235,21 +235,21 @@ ENV COMPOSER_VERSION=1.6.3 \ PLATFORMSH_CLI_VERSION=3.33.5 RUN set -xe; \ # Composer - curl -sSL "https://github.com/composer/composer/releases/download/${COMPOSER_VERSION}/composer.phar" -o /usr/local/bin/composer; \ + curl -fsSL "https://github.com/composer/composer/releases/download/${COMPOSER_VERSION}/composer.phar" -o /usr/local/bin/composer; \ # Drush 8 (default) - curl -sSL "https://github.com/drush-ops/drush/releases/download/${DRUSH_VERSION}/drush.phar" -o /usr/local/bin/drush8; \ + curl -fsSL "https://github.com/drush-ops/drush/releases/download/${DRUSH_VERSION}/drush.phar" -o /usr/local/bin/drush8; \ # Drush Launcher - curl -sSL "https://github.com/drush-ops/drush-launcher/releases/download/${DRUSH_LAUNCHER_VERSION}/drush.phar" -o /usr/local/bin/drush; \ + curl -fsSL "https://github.com/drush-ops/drush-launcher/releases/download/${DRUSH_LAUNCHER_VERSION}/drush.phar" -o /usr/local/bin/drush; \ # Drupal Console - curl -sSL "https://github.com/hechoendrupal/drupal-console-launcher/releases/download/${DRUPAL_CONSOLE_VERSION}/drupal.phar" -o /usr/local/bin/drupal; \ + curl -fsSL "https://github.com/hechoendrupal/drupal-console-launcher/releases/download/${DRUPAL_CONSOLE_VERSION}/drupal.phar" -o /usr/local/bin/drupal; \ # Wordpress CLI - curl -sSL "https://github.com/wp-cli/wp-cli/releases/download/v${WPCLI_VERSION}/wp-cli-${WPCLI_VERSION}.phar" -o /usr/local/bin/wp; \ + curl -fsSL "https://github.com/wp-cli/wp-cli/releases/download/v${WPCLI_VERSION}/wp-cli-${WPCLI_VERSION}.phar" -o /usr/local/bin/wp; \ # Magento2 Code Generator - curl -sSL "https://github.com/staempfli/magento2-code-generator/releases/download/${MG_CODEGEN_VERSION}/mg2-codegen.phar" -o /usr/local/bin/mg2-codegen; \ + curl -fsSL "https://github.com/staempfli/magento2-code-generator/releases/download/${MG_CODEGEN_VERSION}/mg2-codegen.phar" -o /usr/local/bin/mg2-codegen; \ # Blackfire CLI - curl -sSL "https://packages.blackfire.io/binaries/blackfire-agent/${BLACKFIRE_VERSION}/blackfire-cli-linux_static_amd64" -o /usr/local/bin/blackfire; \ + curl -fsSL "https://packages.blackfire.io/binaries/blackfire-agent/${BLACKFIRE_VERSION}/blackfire-cli-linux_static_amd64" -o /usr/local/bin/blackfire; \ # Platform.sh CLI - curl -sSL "https://github.com/platformsh/platformsh-cli/releases/download/v${PLATFORMSH_CLI_VERSION}/platform.phar" -o /usr/local/bin/platform; \ + curl -fsSL "https://github.com/platformsh/platformsh-cli/releases/download/v${PLATFORMSH_CLI_VERSION}/platform.phar" -o /usr/local/bin/platform; \ # Make all downloaded binaries executable in one shot (cd /usr/local/bin && chmod +x composer drush8 drush drupal wp mg2-codegen blackfire platform); @@ -257,11 +257,11 @@ RUN set -xe; \ ENV NODE_VERSION=8.x RUN set -xe; \ # Node.js repo - curl -sSL https://deb.nodesource.com/gpgkey/nodesource.gpg.key | apt-key add -; \ + curl -fsSL https://deb.nodesource.com/gpgkey/nodesource.gpg.key | apt-key add -; \ echo "deb https://deb.nodesource.com/node_${NODE_VERSION} jessie main" | sudo tee /etc/apt/sources.list.d/nodesource.list; \ echo "deb-src https://deb.nodesource.com/node_${NODE_VERSION} jessie main" | sudo tee -a /etc/apt/sources.list.d/nodesource.list; \ # yarn repo - curl -sSL https://dl.yarnpkg.com/debian/pubkey.gpg | apt-key add -; \ + curl -fsSL https://dl.yarnpkg.com/debian/pubkey.gpg | apt-key add -; \ echo "deb https://dl.yarnpkg.com/debian/ stable main" | tee /etc/apt/sources.list.d/yarn.list; \ apt-get update >/dev/null; apt-get -y --force-yes --no-install-recommends install >/dev/null \ nodejs \ diff --git a/7.1/Dockerfile b/7.1/Dockerfile index ff61b975..4402d486 100644 --- a/7.1/Dockerfile +++ b/7.1/Dockerfile @@ -42,14 +42,14 @@ RUN set -xe; \ # backports repo echo "deb http://ftp.debian.org/debian jessie-backports main" | tee /etc/apt/sources.list.d/backports.list; \ # blackfire.io repo - curl -sSL https://packagecloud.io/gpg.key | apt-key add -; \ + curl -fsSL https://packagecloud.io/gpg.key | apt-key add -; \ echo "deb https://packages.blackfire.io/debian any main" | tee /etc/apt/sources.list.d/blackfire.list; \ # git-lfs repo - curl -sSL https://packagecloud.io/github/git-lfs/gpgkey | apt-key add -; \ + curl -fsSL https://packagecloud.io/github/git-lfs/gpgkey | apt-key add -; \ echo 'deb https://packagecloud.io/github/git-lfs/debian/ jessie main' | tee /etc/apt/sources.list.d/github_git-lfs.list; \ echo 'deb-src https://packagecloud.io/github/git-lfs/debian/ jessie main' | tee -a /etc/apt/sources.list.d/github_git-lfs.list; \ # MSQSQL repo - msodbcsql17, pecl/sqlsrv and pecl/pdo_sqlsrv (PHP 7.0+ only) - curl -sSL https://packages.microsoft.com/keys/microsoft.asc | apt-key add -; \ + curl -fsSL https://packages.microsoft.com/keys/microsoft.asc | apt-key add -; \ echo 'deb https://packages.microsoft.com/debian/8/prod jessie main' | tee /etc/apt/sources.list.d/mssql.list; # Additional packages @@ -100,11 +100,11 @@ RUN set -xe; \ # Install gosu and give access to the docker user primary group to use it. # gosu is used instead of sudo to start the main container process (pid 1) in a docker friendly way. # https://github.com/tianon/gosu - curl -sSL "https://github.com/tianon/gosu/releases/download/${GOSU_VERSION}/gosu-$(dpkg --print-architecture)" -o /usr/local/bin/gosu; \ + curl -fsSL "https://github.com/tianon/gosu/releases/download/${GOSU_VERSION}/gosu-$(dpkg --print-architecture)" -o /usr/local/bin/gosu; \ chown root:"$(id -gn docker)" /usr/local/bin/gosu; \ chmod +sx /usr/local/bin/gosu; \ # gomplate (to process configuration templates in startup.sh) - curl -sSL https://github.com/hairyhenderson/gomplate/releases/download/v${GOMPLATE_VERSION}/gomplate_linux-amd64-slim -o /usr/local/bin/gomplate; \ + curl -fsSL https://github.com/hairyhenderson/gomplate/releases/download/v${GOMPLATE_VERSION}/gomplate_linux-amd64-slim -o /usr/local/bin/gomplate; \ chmod +x /usr/local/bin/gomplate # Configure sshd (for use PHPStorm's remote interpreters and tools integrations) @@ -235,21 +235,21 @@ ENV COMPOSER_VERSION=1.6.3 \ PLATFORMSH_CLI_VERSION=3.33.5 RUN set -xe; \ # Composer - curl -sSL "https://github.com/composer/composer/releases/download/${COMPOSER_VERSION}/composer.phar" -o /usr/local/bin/composer; \ + curl -fsSL "https://github.com/composer/composer/releases/download/${COMPOSER_VERSION}/composer.phar" -o /usr/local/bin/composer; \ # Drush 8 (default) - curl -sSL "https://github.com/drush-ops/drush/releases/download/${DRUSH_VERSION}/drush.phar" -o /usr/local/bin/drush8; \ + curl -fsSL "https://github.com/drush-ops/drush/releases/download/${DRUSH_VERSION}/drush.phar" -o /usr/local/bin/drush8; \ # Drush Launcher - curl -sSL "https://github.com/drush-ops/drush-launcher/releases/download/${DRUSH_LAUNCHER_VERSION}/drush.phar" -o /usr/local/bin/drush; \ + curl -fsSL "https://github.com/drush-ops/drush-launcher/releases/download/${DRUSH_LAUNCHER_VERSION}/drush.phar" -o /usr/local/bin/drush; \ # Drupal Console - curl -sSL "https://github.com/hechoendrupal/drupal-console-launcher/releases/download/${DRUPAL_CONSOLE_VERSION}/drupal.phar" -o /usr/local/bin/drupal; \ + curl -fsSL "https://github.com/hechoendrupal/drupal-console-launcher/releases/download/${DRUPAL_CONSOLE_VERSION}/drupal.phar" -o /usr/local/bin/drupal; \ # Wordpress CLI - curl -sSL "https://github.com/wp-cli/wp-cli/releases/download/v${WPCLI_VERSION}/wp-cli-${WPCLI_VERSION}.phar" -o /usr/local/bin/wp; \ + curl -fsSL "https://github.com/wp-cli/wp-cli/releases/download/v${WPCLI_VERSION}/wp-cli-${WPCLI_VERSION}.phar" -o /usr/local/bin/wp; \ # Magento2 Code Generator - curl -sSL "https://github.com/staempfli/magento2-code-generator/releases/download/${MG_CODEGEN_VERSION}/mg2-codegen.phar" -o /usr/local/bin/mg2-codegen; \ + curl -fsSL "https://github.com/staempfli/magento2-code-generator/releases/download/${MG_CODEGEN_VERSION}/mg2-codegen.phar" -o /usr/local/bin/mg2-codegen; \ # Blackfire CLI - curl -sSL "https://packages.blackfire.io/binaries/blackfire-agent/${BLACKFIRE_VERSION}/blackfire-cli-linux_static_amd64" -o /usr/local/bin/blackfire; \ + curl -fsSL "https://packages.blackfire.io/binaries/blackfire-agent/${BLACKFIRE_VERSION}/blackfire-cli-linux_static_amd64" -o /usr/local/bin/blackfire; \ # Platform.sh CLI - curl -sSL "https://github.com/platformsh/platformsh-cli/releases/download/v${PLATFORMSH_CLI_VERSION}/platform.phar" -o /usr/local/bin/platform; \ + curl -fsSL "https://github.com/platformsh/platformsh-cli/releases/download/v${PLATFORMSH_CLI_VERSION}/platform.phar" -o /usr/local/bin/platform; \ # Make all downloaded binaries executable in one shot (cd /usr/local/bin && chmod +x composer drush8 drush drupal wp mg2-codegen blackfire platform); @@ -257,11 +257,11 @@ RUN set -xe; \ ENV NODE_VERSION=8.x RUN set -xe; \ # Node.js repo - curl -sSL https://deb.nodesource.com/gpgkey/nodesource.gpg.key | apt-key add -; \ + curl -fsSL https://deb.nodesource.com/gpgkey/nodesource.gpg.key | apt-key add -; \ echo "deb https://deb.nodesource.com/node_${NODE_VERSION} jessie main" | sudo tee /etc/apt/sources.list.d/nodesource.list; \ echo "deb-src https://deb.nodesource.com/node_${NODE_VERSION} jessie main" | sudo tee -a /etc/apt/sources.list.d/nodesource.list; \ # yarn repo - curl -sSL https://dl.yarnpkg.com/debian/pubkey.gpg | apt-key add -; \ + curl -fsSL https://dl.yarnpkg.com/debian/pubkey.gpg | apt-key add -; \ echo "deb https://dl.yarnpkg.com/debian/ stable main" | tee /etc/apt/sources.list.d/yarn.list; \ apt-get update >/dev/null; apt-get -y --force-yes --no-install-recommends install >/dev/null \ nodejs \ diff --git a/7.2/Dockerfile b/7.2/Dockerfile index da14899e..fa36c258 100644 --- a/7.2/Dockerfile +++ b/7.2/Dockerfile @@ -42,14 +42,14 @@ RUN set -xe; \ # backports repo echo "deb http://ftp.debian.org/debian jessie-backports main" | tee /etc/apt/sources.list.d/backports.list; \ # blackfire.io repo - curl -sSL https://packagecloud.io/gpg.key | apt-key add -; \ + curl -fsSL https://packagecloud.io/gpg.key | apt-key add -; \ echo "deb https://packages.blackfire.io/debian any main" | tee /etc/apt/sources.list.d/blackfire.list; \ # git-lfs repo - curl -sSL https://packagecloud.io/github/git-lfs/gpgkey | apt-key add -; \ + curl -fsSL https://packagecloud.io/github/git-lfs/gpgkey | apt-key add -; \ echo 'deb https://packagecloud.io/github/git-lfs/debian/ jessie main' | tee /etc/apt/sources.list.d/github_git-lfs.list; \ echo 'deb-src https://packagecloud.io/github/git-lfs/debian/ jessie main' | tee -a /etc/apt/sources.list.d/github_git-lfs.list; \ # MSQSQL repo - msodbcsql17, pecl/sqlsrv and pecl/pdo_sqlsrv (PHP 7.0+ only) - curl -sSL https://packages.microsoft.com/keys/microsoft.asc | apt-key add -; \ + curl -fsSL https://packages.microsoft.com/keys/microsoft.asc | apt-key add -; \ echo 'deb https://packages.microsoft.com/debian/8/prod jessie main' | tee /etc/apt/sources.list.d/mssql.list; # Additional packages @@ -100,11 +100,11 @@ RUN set -xe; \ # Install gosu and give access to the docker user primary group to use it. # gosu is used instead of sudo to start the main container process (pid 1) in a docker friendly way. # https://github.com/tianon/gosu - curl -sSL "https://github.com/tianon/gosu/releases/download/${GOSU_VERSION}/gosu-$(dpkg --print-architecture)" -o /usr/local/bin/gosu; \ + curl -fsSL "https://github.com/tianon/gosu/releases/download/${GOSU_VERSION}/gosu-$(dpkg --print-architecture)" -o /usr/local/bin/gosu; \ chown root:"$(id -gn docker)" /usr/local/bin/gosu; \ chmod +sx /usr/local/bin/gosu; \ # gomplate (to process configuration templates in startup.sh) - curl -sSL https://github.com/hairyhenderson/gomplate/releases/download/v${GOMPLATE_VERSION}/gomplate_linux-amd64-slim -o /usr/local/bin/gomplate; \ + curl -fsSL https://github.com/hairyhenderson/gomplate/releases/download/v${GOMPLATE_VERSION}/gomplate_linux-amd64-slim -o /usr/local/bin/gomplate; \ chmod +x /usr/local/bin/gomplate # Configure sshd (for use PHPStorm's remote interpreters and tools integrations) @@ -237,21 +237,21 @@ ENV COMPOSER_VERSION=1.6.3 \ PLATFORMSH_CLI_VERSION=3.33.5 RUN set -xe; \ # Composer - curl -sSL "https://github.com/composer/composer/releases/download/${COMPOSER_VERSION}/composer.phar" -o /usr/local/bin/composer; \ + curl -fsSL "https://github.com/composer/composer/releases/download/${COMPOSER_VERSION}/composer.phar" -o /usr/local/bin/composer; \ # Drush 8 (default) - curl -sSL "https://github.com/drush-ops/drush/releases/download/${DRUSH_VERSION}/drush.phar" -o /usr/local/bin/drush8; \ + curl -fsSL "https://github.com/drush-ops/drush/releases/download/${DRUSH_VERSION}/drush.phar" -o /usr/local/bin/drush8; \ # Drush Launcher - curl -sSL "https://github.com/drush-ops/drush-launcher/releases/download/${DRUSH_LAUNCHER_VERSION}/drush.phar" -o /usr/local/bin/drush; \ + curl -fsSL "https://github.com/drush-ops/drush-launcher/releases/download/${DRUSH_LAUNCHER_VERSION}/drush.phar" -o /usr/local/bin/drush; \ # Drupal Console - curl -sSL "https://github.com/hechoendrupal/drupal-console-launcher/releases/download/${DRUPAL_CONSOLE_VERSION}/drupal.phar" -o /usr/local/bin/drupal; \ + curl -fsSL "https://github.com/hechoendrupal/drupal-console-launcher/releases/download/${DRUPAL_CONSOLE_VERSION}/drupal.phar" -o /usr/local/bin/drupal; \ # Wordpress CLI - curl -sSL "https://github.com/wp-cli/wp-cli/releases/download/v${WPCLI_VERSION}/wp-cli-${WPCLI_VERSION}.phar" -o /usr/local/bin/wp; \ + curl -fsSL "https://github.com/wp-cli/wp-cli/releases/download/v${WPCLI_VERSION}/wp-cli-${WPCLI_VERSION}.phar" -o /usr/local/bin/wp; \ # Magento2 Code Generator - curl -sSL "https://github.com/staempfli/magento2-code-generator/releases/download/${MG_CODEGEN_VERSION}/mg2-codegen.phar" -o /usr/local/bin/mg2-codegen; \ + curl -fsSL "https://github.com/staempfli/magento2-code-generator/releases/download/${MG_CODEGEN_VERSION}/mg2-codegen.phar" -o /usr/local/bin/mg2-codegen; \ # Blackfire CLI - curl -sSL "https://packages.blackfire.io/binaries/blackfire-agent/${BLACKFIRE_VERSION}/blackfire-cli-linux_static_amd64" -o /usr/local/bin/blackfire; \ + curl -fsSL "https://packages.blackfire.io/binaries/blackfire-agent/${BLACKFIRE_VERSION}/blackfire-cli-linux_static_amd64" -o /usr/local/bin/blackfire; \ # Platform.sh CLI - curl -sSL "https://github.com/platformsh/platformsh-cli/releases/download/v${PLATFORMSH_CLI_VERSION}/platform.phar" -o /usr/local/bin/platform; \ + curl -fsSL "https://github.com/platformsh/platformsh-cli/releases/download/v${PLATFORMSH_CLI_VERSION}/platform.phar" -o /usr/local/bin/platform; \ # Make all downloaded binaries executable in one shot (cd /usr/local/bin && chmod +x composer drush8 drush drupal wp mg2-codegen blackfire platform); @@ -259,11 +259,11 @@ RUN set -xe; \ ENV NODE_VERSION=8.x RUN set -xe; \ # Node.js repo - curl -sSL https://deb.nodesource.com/gpgkey/nodesource.gpg.key | apt-key add -; \ + curl -fsSL https://deb.nodesource.com/gpgkey/nodesource.gpg.key | apt-key add -; \ echo "deb https://deb.nodesource.com/node_${NODE_VERSION} jessie main" | sudo tee /etc/apt/sources.list.d/nodesource.list; \ echo "deb-src https://deb.nodesource.com/node_${NODE_VERSION} jessie main" | sudo tee -a /etc/apt/sources.list.d/nodesource.list; \ # yarn repo - curl -sSL https://dl.yarnpkg.com/debian/pubkey.gpg | apt-key add -; \ + curl -fsSL https://dl.yarnpkg.com/debian/pubkey.gpg | apt-key add -; \ echo "deb https://dl.yarnpkg.com/debian/ stable main" | tee /etc/apt/sources.list.d/yarn.list; \ apt-get update >/dev/null; apt-get -y --force-yes --no-install-recommends install >/dev/null \ nodejs \ From f70f8b808e3dee8036041fa12c05e461c13fdf86 Mon Sep 17 00:00:00 2001 From: Leonid Makarov Date: Fri, 6 Jul 2018 16:33:32 -0700 Subject: [PATCH 23/45] Removed --force-yes from apt-get install It's deprecated and should not be used --- 5.6/Dockerfile | 17 +++++++++++------ 7.0/Dockerfile | 16 ++++++++++------ 7.1/Dockerfile | 16 ++++++++++------ 7.2/Dockerfile | 16 ++++++++++------ 4 files changed, 41 insertions(+), 24 deletions(-) diff --git a/5.6/Dockerfile b/5.6/Dockerfile index c2263d86..5e997f25 100644 --- a/5.6/Dockerfile +++ b/5.6/Dockerfile @@ -18,7 +18,8 @@ RUN set -xe; \ # Install basic packages RUN set -xe; \ - apt-get update >/dev/null; apt-get -y --force-yes --no-install-recommends install >/dev/null \ + apt-get update >/dev/null; \ + apt-get -y --no-install-recommends install >/dev/null \ apt-transport-https \ ca-certificates \ curl \ @@ -54,7 +55,8 @@ RUN set -xe; \ # Create man direcotries, otherwise some packages may not install (e.g. postgresql-client) # This should be a temporary workaround until fixed upstream: https://github.com/debuerreotype/debuerreotype/issues/10 mkdir -p /usr/share/man/man1 /usr/share/man/man7; \ - apt-get update >/dev/null; apt-get -y --force-yes --no-install-recommends install >/dev/null \ + apt-get update >/dev/null; \ + apt-get -y --no-install-recommends install >/dev/null \ cron \ dnsutils \ git-lfs \ @@ -81,7 +83,7 @@ RUN set -xe; \ zsh \ ;\ # More recent version of git to get composer's git cache. - apt-get -y --force-yes --no-install-recommends -t jessie-backports install git >/dev/null ;\ + apt-get -y --no-install-recommends -t jessie-backports install git >/dev/null ;\ # Cleanup apt-get clean; rm -rf /var/lib/apt/lists/* @@ -138,7 +140,8 @@ RUN set -xe; \ libxslt1-dev \ zlib1g-dev \ "; \ - apt-get update >/dev/null; apt-get -y --force-yes --no-install-recommends install >/dev/null \ + apt-get update >/dev/null; \ + apt-get -y --no-install-recommends install >/dev/null \ $buildDeps \ blackfire-php \ libc-client2007e \ @@ -254,7 +257,8 @@ RUN set -xe; \ # yarn repo curl -fsSL https://dl.yarnpkg.com/debian/pubkey.gpg | apt-key add -; \ echo "deb https://dl.yarnpkg.com/debian/ stable main" | tee /etc/apt/sources.list.d/yarn.list; \ - apt-get update >/dev/null; apt-get -y --force-yes --no-install-recommends install >/dev/null \ + apt-get update >/dev/null; \ + apt-get -y --no-install-recommends install >/dev/null \ nodejs \ yarn \ ;\ @@ -262,7 +266,8 @@ RUN set -xe; \ # Ruby RUN set -xe; \ - apt-get update >/dev/null; apt-get -y --force-yes --no-install-recommends install >/dev/null \ + apt-get update >/dev/null; \ + apt-get -y --no-install-recommends install >/dev/null \ ruby-full \ rlwrap \ ;\ diff --git a/7.0/Dockerfile b/7.0/Dockerfile index 2e53db13..ac980274 100644 --- a/7.0/Dockerfile +++ b/7.0/Dockerfile @@ -18,7 +18,8 @@ RUN set -xe; \ # Install basic packages RUN set -xe; \ - apt-get update >/dev/null; apt-get -y --force-yes --no-install-recommends install >/dev/null \ + apt-get update >/dev/null; \ + apt-get -y --no-install-recommends install >/dev/null \ apt-transport-https \ ca-certificates \ curl \ @@ -57,7 +58,8 @@ RUN set -xe; \ # Create man direcotries, otherwise some packages may not install (e.g. postgresql-client) # This should be a temporary workaround until fixed upstream: https://github.com/debuerreotype/debuerreotype/issues/10 mkdir -p /usr/share/man/man1 /usr/share/man/man7; \ - apt-get update >/dev/null; apt-get -y --force-yes --no-install-recommends install >/dev/null \ + apt-get update >/dev/null; \ + apt-get -y --no-install-recommends install >/dev/null \ cron \ dnsutils \ git-lfs \ @@ -84,7 +86,7 @@ RUN set -xe; \ zsh \ ;\ # More recent version of git to get composer's git cache. - apt-get -y --force-yes --no-install-recommends -t jessie-backports install git >/dev/null ;\ + apt-get -y --no-install-recommends -t jessie-backports install git >/dev/null ;\ # Cleanup apt-get clean; rm -rf /var/lib/apt/lists/* @@ -144,7 +146,7 @@ RUN set -xe; \ apt-get update >/dev/null; \ # Necessary for msodbcsql17 (MSSQL) ACCEPT_EULA=Y \ - apt-get -y --force-yes --no-install-recommends install >/dev/null \ + apt-get -y --no-install-recommends install >/dev/null \ $buildDeps \ blackfire-php \ libc-client2007e \ @@ -263,7 +265,8 @@ RUN set -xe; \ # yarn repo curl -fsSL https://dl.yarnpkg.com/debian/pubkey.gpg | apt-key add -; \ echo "deb https://dl.yarnpkg.com/debian/ stable main" | tee /etc/apt/sources.list.d/yarn.list; \ - apt-get update >/dev/null; apt-get -y --force-yes --no-install-recommends install >/dev/null \ + apt-get update >/dev/null; \ + apt-get -y --no-install-recommends install >/dev/null \ nodejs \ yarn \ ;\ @@ -271,7 +274,8 @@ RUN set -xe; \ # Ruby RUN set -xe; \ - apt-get update >/dev/null; apt-get -y --force-yes --no-install-recommends install >/dev/null \ + apt-get update >/dev/null; \ + apt-get -y --no-install-recommends install >/dev/null \ ruby-full \ rlwrap \ ;\ diff --git a/7.1/Dockerfile b/7.1/Dockerfile index 4402d486..2c009662 100644 --- a/7.1/Dockerfile +++ b/7.1/Dockerfile @@ -18,7 +18,8 @@ RUN set -xe; \ # Install basic packages RUN set -xe; \ - apt-get update >/dev/null; apt-get -y --force-yes --no-install-recommends install >/dev/null \ + apt-get update >/dev/null; \ + apt-get -y --no-install-recommends install >/dev/null \ apt-transport-https \ ca-certificates \ curl \ @@ -57,7 +58,8 @@ RUN set -xe; \ # Create man direcotries, otherwise some packages may not install (e.g. postgresql-client) # This should be a temporary workaround until fixed upstream: https://github.com/debuerreotype/debuerreotype/issues/10 mkdir -p /usr/share/man/man1 /usr/share/man/man7; \ - apt-get update >/dev/null; apt-get -y --force-yes --no-install-recommends install >/dev/null \ + apt-get update >/dev/null; \ + apt-get -y --no-install-recommends install >/dev/null \ cron \ dnsutils \ git-lfs \ @@ -84,7 +86,7 @@ RUN set -xe; \ zsh \ ;\ # More recent version of git to get composer's git cache. - apt-get -y --force-yes --no-install-recommends -t jessie-backports install git >/dev/null ;\ + apt-get -y --no-install-recommends -t jessie-backports install git >/dev/null ;\ # Cleanup apt-get clean; rm -rf /var/lib/apt/lists/* @@ -144,7 +146,7 @@ RUN set -xe; \ apt-get update >/dev/null; \ # Necessary for msodbcsql17 (MSSQL) ACCEPT_EULA=Y \ - apt-get -y --force-yes --no-install-recommends install >/dev/null \ + apt-get -y --no-install-recommends install >/dev/null \ $buildDeps \ blackfire-php \ libc-client2007e \ @@ -263,7 +265,8 @@ RUN set -xe; \ # yarn repo curl -fsSL https://dl.yarnpkg.com/debian/pubkey.gpg | apt-key add -; \ echo "deb https://dl.yarnpkg.com/debian/ stable main" | tee /etc/apt/sources.list.d/yarn.list; \ - apt-get update >/dev/null; apt-get -y --force-yes --no-install-recommends install >/dev/null \ + apt-get update >/dev/null; \ + apt-get -y --no-install-recommends install >/dev/null \ nodejs \ yarn \ ;\ @@ -271,7 +274,8 @@ RUN set -xe; \ # Ruby RUN set -xe; \ - apt-get update >/dev/null; apt-get -y --force-yes --no-install-recommends install >/dev/null \ + apt-get update >/dev/null; \ + apt-get -y --no-install-recommends install >/dev/null \ ruby-full \ rlwrap \ ;\ diff --git a/7.2/Dockerfile b/7.2/Dockerfile index fa36c258..3e853a47 100644 --- a/7.2/Dockerfile +++ b/7.2/Dockerfile @@ -18,7 +18,8 @@ RUN set -xe; \ # Install basic packages RUN set -xe; \ - apt-get update >/dev/null; apt-get -y --force-yes --no-install-recommends install >/dev/null \ + apt-get update >/dev/null; \ + apt-get -y --no-install-recommends install >/dev/null \ apt-transport-https \ ca-certificates \ curl \ @@ -57,7 +58,8 @@ RUN set -xe; \ # Create man direcotries, otherwise some packages may not install (e.g. postgresql-client) # This should be a temporary workaround until fixed upstream: https://github.com/debuerreotype/debuerreotype/issues/10 mkdir -p /usr/share/man/man1 /usr/share/man/man7; \ - apt-get update >/dev/null; apt-get -y --force-yes --no-install-recommends install >/dev/null \ + apt-get update >/dev/null; \ + apt-get -y --no-install-recommends install >/dev/null \ cron \ dnsutils \ git-lfs \ @@ -84,7 +86,7 @@ RUN set -xe; \ zsh \ ;\ # More recent version of git to get composer's git cache. - apt-get -y --force-yes --no-install-recommends -t jessie-backports install git >/dev/null ;\ + apt-get -y --no-install-recommends -t jessie-backports install git >/dev/null ;\ # Cleanup apt-get clean; rm -rf /var/lib/apt/lists/* @@ -144,7 +146,7 @@ RUN set -xe; \ apt-get update >/dev/null; \ # Necessary for msodbcsql17 (MSSQL) ACCEPT_EULA=Y \ - apt-get -y --force-yes --no-install-recommends install >/dev/null \ + apt-get -y --no-install-recommends install >/dev/null \ $buildDeps \ blackfire-php \ libc-client2007e \ @@ -265,7 +267,8 @@ RUN set -xe; \ # yarn repo curl -fsSL https://dl.yarnpkg.com/debian/pubkey.gpg | apt-key add -; \ echo "deb https://dl.yarnpkg.com/debian/ stable main" | tee /etc/apt/sources.list.d/yarn.list; \ - apt-get update >/dev/null; apt-get -y --force-yes --no-install-recommends install >/dev/null \ + apt-get update >/dev/null; \ + apt-get -y --no-install-recommends install >/dev/null \ nodejs \ yarn \ ;\ @@ -273,7 +276,8 @@ RUN set -xe; \ # Ruby RUN set -xe; \ - apt-get update >/dev/null; apt-get -y --force-yes --no-install-recommends install >/dev/null \ + apt-get update >/dev/null; \ + apt-get -y --no-install-recommends install >/dev/null \ ruby-full \ rlwrap \ ;\ From a01757596e06e1129323a89edbd3b05aff6a071f Mon Sep 17 00:00:00 2001 From: Leonid Makarov Date: Fri, 6 Jul 2018 16:34:50 -0700 Subject: [PATCH 24/45] Suppress apt-key warnings "Warning: apt-key output should not be parsed (stdout is not a terminal)" --- 5.6/Dockerfile | 1 + 7.0/Dockerfile | 1 + 7.1/Dockerfile | 1 + 7.2/Dockerfile | 1 + 4 files changed, 4 insertions(+) diff --git a/5.6/Dockerfile b/5.6/Dockerfile index 5e997f25..f87a426e 100644 --- a/5.6/Dockerfile +++ b/5.6/Dockerfile @@ -11,6 +11,7 @@ RUN set -xe; \ FROM php:5.6-fpm ARG DEBIAN_FRONTEND=noninteractive +ARG APT_KEY_DONT_WARN_ON_DANGEROUS_USAGE=1 # Prevent services autoload (http://jpetazzo.github.io/2013/10/06/policy-rc-d-do-not-start-services-automatically/) RUN set -xe; \ diff --git a/7.0/Dockerfile b/7.0/Dockerfile index ac980274..e28e6e26 100644 --- a/7.0/Dockerfile +++ b/7.0/Dockerfile @@ -11,6 +11,7 @@ RUN set -xe; \ FROM php:7.0-fpm ARG DEBIAN_FRONTEND=noninteractive +ARG APT_KEY_DONT_WARN_ON_DANGEROUS_USAGE=1 # Prevent services autoload (http://jpetazzo.github.io/2013/10/06/policy-rc-d-do-not-start-services-automatically/) RUN set -xe; \ diff --git a/7.1/Dockerfile b/7.1/Dockerfile index 2c009662..bb820fc0 100644 --- a/7.1/Dockerfile +++ b/7.1/Dockerfile @@ -11,6 +11,7 @@ RUN set -xe; \ FROM php:7.1-fpm ARG DEBIAN_FRONTEND=noninteractive +ARG APT_KEY_DONT_WARN_ON_DANGEROUS_USAGE=1 # Prevent services autoload (http://jpetazzo.github.io/2013/10/06/policy-rc-d-do-not-start-services-automatically/) RUN set -xe; \ diff --git a/7.2/Dockerfile b/7.2/Dockerfile index 3e853a47..fa62d701 100644 --- a/7.2/Dockerfile +++ b/7.2/Dockerfile @@ -11,6 +11,7 @@ RUN set -xe; \ FROM php:7.2-fpm ARG DEBIAN_FRONTEND=noninteractive +ARG APT_KEY_DONT_WARN_ON_DANGEROUS_USAGE=1 # Prevent services autoload (http://jpetazzo.github.io/2013/10/06/policy-rc-d-do-not-start-services-automatically/) RUN set -xe; \ From cae1b03e6e323ae02aa313a8d7c1e6e1a806635f Mon Sep 17 00:00:00 2001 From: Leonid Makarov Date: Fri, 6 Jul 2018 16:43:22 -0700 Subject: [PATCH 25/45] Fixed an orphaned curl -fssL in 5.6 --- 5.6/Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/5.6/Dockerfile b/5.6/Dockerfile index f87a426e..3fbcc0e6 100644 --- a/5.6/Dockerfile +++ b/5.6/Dockerfile @@ -44,7 +44,7 @@ RUN set -xe; \ # backports repo echo "deb http://ftp.debian.org/debian jessie-backports main" | tee /etc/apt/sources.list.d/backports.list; \ # blackfire.io repo - curl -fssL https://packagecloud.io/gpg.key | apt-key add -; \ + curl -fsSL https://packagecloud.io/gpg.key | apt-key add -; \ echo "deb https://packages.blackfire.io/debian any main" | tee /etc/apt/sources.list.d/blackfire.list; \ # git-lfs repo curl -fsSL https://packagecloud.io/github/git-lfs/gpgkey | apt-key add -; \ From 510ad2dfd6684695da9ef6ae3c5772709c513a42 Mon Sep 17 00:00:00 2001 From: Leonid Makarov Date: Fri, 6 Jul 2018 16:48:50 -0700 Subject: [PATCH 26/45] Use consolidation/cgr instead of `composer global require` cgr handles installing global composer dependencies into individual folders automatically --- 5.6/Dockerfile | 33 +++++++++++++++++---------------- 7.0/Dockerfile | 33 +++++++++++++++++---------------- 7.1/Dockerfile | 33 +++++++++++++++++---------------- 7.2/Dockerfile | 33 +++++++++++++++++---------------- 4 files changed, 68 insertions(+), 64 deletions(-) diff --git a/5.6/Dockerfile b/5.6/Dockerfile index 3fbcc0e6..d59e13da 100644 --- a/5.6/Dockerfile +++ b/5.6/Dockerfile @@ -219,6 +219,7 @@ RUN set -xe; \ apt-get purge -y --auto-remove -o APT::AutoRemove::RecommendsImportant=false $buildDeps >/dev/null; \ apt-get clean; rm -rf /var/lib/apt/lists/* +# PHP tools (installed globally) ENV COMPOSER_VERSION=1.6.3 \ DRUSH_VERSION=8.1.16 \ DRUSH_LAUNCHER_VERSION=0.6.0 \ @@ -281,31 +282,31 @@ ENV BUNDLE_PATH .bundler # All further RUN commands will run as the "docker" user USER docker -ENV HOME /home/docker +ARG HOME=/home/docker -# Install Composer based dependencies -ENV PATH=$PATH:$HOME/.composer/vendor/bin -ENV PATH=$PATH:$HOME/.terminus/vendor/bin \ +# PHP tools (installed as user) +ENV PATH=$PATH:$HOME/.composer/vendor/bin \ TERMINUS_VERSION=1.8.1 RUN set -xe; \ + \ + # Composer based dependencies # Add composer bin directory to PATH echo "\n"'PATH="$PATH:$HOME/.composer/vendor/bin"' >> $HOME/.profile; \ - # Drush modules - drush dl registry_rebuild --default-major=7 --destination=$HOME/.drush >/dev/null; \ - drush cc drush; \ - # Drupal Coder w/ a matching version of PHP_CodeSniffer - composer global require drupal/coder >/dev/null; \ - phpcs --config-set installed_paths $HOME/.composer/vendor/drupal/coder/coder_sniffer; \ + # Install cgr to use it in-place of `composer global require` + composer global require consolidation/cgr >/dev/null; \ # Composer parallel install plugin composer global require hirak/prestissimo >/dev/null; \ + # Drupal Coder w/ a matching version of PHP_CodeSniffer + cgr drupal/coder >/dev/null; \ + phpcs --config-set installed_paths $HOME/.composer/vendor/drupal/coder/coder_sniffer; \ # Terminus - # Installed in a dedicated directory to avoid dependency conflicts. - echo "\n"'PATH="$PATH:$HOME/.terminus/vendor/bin"' >> $HOME/.profile; \ - mkdir -p $HOME/.terminus; \ - # Run in a subshell since we are doing directory switching - (cd $HOME/.terminus && composer require pantheon-systems/terminus:${TERMINUS_VERSION}); \ + cgr pantheon-systems/terminus:${TERMINUS_VERSION} >/dev/null; \ # Cleanup - composer clear-cache + composer clear-cache; \ + \ + # Drush modules + drush dl registry_rebuild --default-major=7 --destination=$HOME/.drush >/dev/null; \ + drush cc drush USER root diff --git a/7.0/Dockerfile b/7.0/Dockerfile index e28e6e26..34b91529 100644 --- a/7.0/Dockerfile +++ b/7.0/Dockerfile @@ -227,6 +227,7 @@ RUN set -xe; \ apt-get purge -y --auto-remove -o APT::AutoRemove::RecommendsImportant=false $buildDeps >/dev/null; \ apt-get clean; rm -rf /var/lib/apt/lists/* +# PHP tools (installed globally) ENV COMPOSER_VERSION=1.6.3 \ DRUSH_VERSION=8.1.16 \ DRUSH_LAUNCHER_VERSION=0.6.0 \ @@ -289,31 +290,31 @@ ENV BUNDLE_PATH .bundler # All further RUN commands will run as the "docker" user USER docker -ENV HOME /home/docker +ARG HOME=/home/docker -# Install Composer based dependencies -ENV PATH=$PATH:$HOME/.composer/vendor/bin -ENV PATH=$PATH:$HOME/.terminus/vendor/bin \ +# PHP tools (installed as user) +ENV PATH=$PATH:$HOME/.composer/vendor/bin \ TERMINUS_VERSION=1.8.1 RUN set -xe; \ + \ + # Composer based dependencies # Add composer bin directory to PATH echo "\n"'PATH="$PATH:$HOME/.composer/vendor/bin"' >> $HOME/.profile; \ - # Drush modules - drush dl registry_rebuild --default-major=7 --destination=$HOME/.drush >/dev/null; \ - drush cc drush; \ - # Drupal Coder w/ a matching version of PHP_CodeSniffer - composer global require drupal/coder >/dev/null; \ - phpcs --config-set installed_paths $HOME/.composer/vendor/drupal/coder/coder_sniffer; \ + # Install cgr to use it in-place of `composer global require` + composer global require consolidation/cgr >/dev/null; \ # Composer parallel install plugin composer global require hirak/prestissimo >/dev/null; \ + # Drupal Coder w/ a matching version of PHP_CodeSniffer + cgr drupal/coder >/dev/null; \ + phpcs --config-set installed_paths $HOME/.composer/vendor/drupal/coder/coder_sniffer; \ # Terminus - # Installed in a dedicated directory to avoid dependency conflicts. - echo "\n"'PATH="$PATH:$HOME/.terminus/vendor/bin"' >> $HOME/.profile; \ - mkdir -p $HOME/.terminus; \ - # Run in a subshell since we are doing directory switching - (cd $HOME/.terminus && composer require pantheon-systems/terminus:${TERMINUS_VERSION}); \ + cgr pantheon-systems/terminus:${TERMINUS_VERSION} >/dev/null; \ # Cleanup - composer clear-cache + composer clear-cache; \ + \ + # Drush modules + drush dl registry_rebuild --default-major=7 --destination=$HOME/.drush >/dev/null; \ + drush cc drush USER root diff --git a/7.1/Dockerfile b/7.1/Dockerfile index bb820fc0..28b526e9 100644 --- a/7.1/Dockerfile +++ b/7.1/Dockerfile @@ -227,6 +227,7 @@ RUN set -xe; \ apt-get purge -y --auto-remove -o APT::AutoRemove::RecommendsImportant=false $buildDeps >/dev/null; \ apt-get clean; rm -rf /var/lib/apt/lists/* +# PHP tools (installed globally) ENV COMPOSER_VERSION=1.6.3 \ DRUSH_VERSION=8.1.16 \ DRUSH_LAUNCHER_VERSION=0.6.0 \ @@ -289,31 +290,31 @@ ENV BUNDLE_PATH .bundler # All further RUN commands will run as the "docker" user USER docker -ENV HOME /home/docker +ARG HOME=/home/docker -# Install Composer based dependencies -ENV PATH=$PATH:$HOME/.composer/vendor/bin -ENV PATH=$PATH:$HOME/.terminus/vendor/bin \ +# PHP tools (installed as user) +ENV PATH=$PATH:$HOME/.composer/vendor/bin \ TERMINUS_VERSION=1.8.1 RUN set -xe; \ + \ + # Composer based dependencies # Add composer bin directory to PATH echo "\n"'PATH="$PATH:$HOME/.composer/vendor/bin"' >> $HOME/.profile; \ - # Drush modules - drush dl registry_rebuild --default-major=7 --destination=$HOME/.drush >/dev/null; \ - drush cc drush; \ - # Drupal Coder w/ a matching version of PHP_CodeSniffer - composer global require drupal/coder >/dev/null; \ - phpcs --config-set installed_paths $HOME/.composer/vendor/drupal/coder/coder_sniffer; \ + # Install cgr to use it in-place of `composer global require` + composer global require consolidation/cgr >/dev/null; \ # Composer parallel install plugin composer global require hirak/prestissimo >/dev/null; \ + # Drupal Coder w/ a matching version of PHP_CodeSniffer + cgr drupal/coder >/dev/null; \ + phpcs --config-set installed_paths $HOME/.composer/vendor/drupal/coder/coder_sniffer; \ # Terminus - # Installed in a dedicated directory to avoid dependency conflicts. - echo "\n"'PATH="$PATH:$HOME/.terminus/vendor/bin"' >> $HOME/.profile; \ - mkdir -p $HOME/.terminus; \ - # Run in a subshell since we are doing directory switching - (cd $HOME/.terminus && composer require pantheon-systems/terminus:${TERMINUS_VERSION}); \ + cgr pantheon-systems/terminus:${TERMINUS_VERSION} >/dev/null; \ # Cleanup - composer clear-cache + composer clear-cache; \ + \ + # Drush modules + drush dl registry_rebuild --default-major=7 --destination=$HOME/.drush >/dev/null; \ + drush cc drush USER root diff --git a/7.2/Dockerfile b/7.2/Dockerfile index fa62d701..176192e6 100644 --- a/7.2/Dockerfile +++ b/7.2/Dockerfile @@ -229,6 +229,7 @@ RUN set -xe; \ apt-get purge -y --auto-remove -o APT::AutoRemove::RecommendsImportant=false $buildDeps >/dev/null; \ apt-get clean; rm -rf /var/lib/apt/lists/* +# PHP tools (installed globally) ENV COMPOSER_VERSION=1.6.3 \ DRUSH_VERSION=8.1.16 \ DRUSH_LAUNCHER_VERSION=0.6.0 \ @@ -291,31 +292,31 @@ ENV BUNDLE_PATH .bundler # All further RUN commands will run as the "docker" user USER docker -ENV HOME /home/docker +ARG HOME=/home/docker -# Install Composer based dependencies -ENV PATH=$PATH:$HOME/.composer/vendor/bin -ENV PATH=$PATH:$HOME/.terminus/vendor/bin \ +# PHP tools (installed as user) +ENV PATH=$PATH:$HOME/.composer/vendor/bin \ TERMINUS_VERSION=1.8.1 RUN set -xe; \ + \ + # Composer based dependencies # Add composer bin directory to PATH echo "\n"'PATH="$PATH:$HOME/.composer/vendor/bin"' >> $HOME/.profile; \ - # Drush modules - drush dl registry_rebuild --default-major=7 --destination=$HOME/.drush >/dev/null; \ - drush cc drush; \ - # Drupal Coder w/ a matching version of PHP_CodeSniffer - composer global require drupal/coder >/dev/null; \ - phpcs --config-set installed_paths $HOME/.composer/vendor/drupal/coder/coder_sniffer; \ + # Install cgr to use it in-place of `composer global require` + composer global require consolidation/cgr >/dev/null; \ # Composer parallel install plugin composer global require hirak/prestissimo >/dev/null; \ + # Drupal Coder w/ a matching version of PHP_CodeSniffer + cgr drupal/coder >/dev/null; \ + phpcs --config-set installed_paths $HOME/.composer/vendor/drupal/coder/coder_sniffer; \ # Terminus - # Installed in a dedicated directory to avoid dependency conflicts. - echo "\n"'PATH="$PATH:$HOME/.terminus/vendor/bin"' >> $HOME/.profile; \ - mkdir -p $HOME/.terminus; \ - # Run in a subshell since we are doing directory switching - (cd $HOME/.terminus && composer require pantheon-systems/terminus:${TERMINUS_VERSION}); \ + cgr pantheon-systems/terminus:${TERMINUS_VERSION} >/dev/null; \ # Cleanup - composer clear-cache + composer clear-cache; \ + \ + # Drush modules + drush dl registry_rebuild --default-major=7 --destination=$HOME/.drush >/dev/null; \ + drush cc drush USER root From c6ddeb4081233f43a830024e305ac7595aa96ee3 Mon Sep 17 00:00:00 2001 From: Leonid Makarov Date: Fri, 6 Jul 2018 16:52:46 -0700 Subject: [PATCH 27/45] Switch to installing mg2-codegen via Composer See: - https://github.com/staempfli/magento2-code-generator/issues/11 - https://github.com/staempfli/magento2-code-generator/issues/15 --- 5.6/Dockerfile | 8 ++++---- 7.0/Dockerfile | 8 ++++---- 7.1/Dockerfile | 8 ++++---- 7.2/Dockerfile | 8 ++++---- tests/test.bats | 7 ++++--- 5 files changed, 20 insertions(+), 19 deletions(-) diff --git a/5.6/Dockerfile b/5.6/Dockerfile index d59e13da..a418fda9 100644 --- a/5.6/Dockerfile +++ b/5.6/Dockerfile @@ -226,7 +226,6 @@ ENV COMPOSER_VERSION=1.6.3 \ DRUSH_LAUNCHER_FALLBACK=/usr/local/bin/drush8 \ DRUPAL_CONSOLE_VERSION=1.7.0 \ WPCLI_VERSION=1.5.0 \ - MG_CODEGEN_VERSION=1.10 \ BLACKFIRE_VERSION=1.15.0 \ PLATFORMSH_CLI_VERSION=3.33.5 RUN set -xe; \ @@ -240,14 +239,12 @@ RUN set -xe; \ curl -fsSL "https://github.com/hechoendrupal/drupal-console-launcher/releases/download/${DRUPAL_CONSOLE_VERSION}/drupal.phar" -o /usr/local/bin/drupal; \ # Wordpress CLI curl -fsSL "https://github.com/wp-cli/wp-cli/releases/download/v${WPCLI_VERSION}/wp-cli-${WPCLI_VERSION}.phar" -o /usr/local/bin/wp; \ - # Magento2 Code Generator - curl -fsSL "https://github.com/staempfli/magento2-code-generator/releases/download/${MG_CODEGEN_VERSION}/mg2-codegen.phar" -o /usr/local/bin/mg2-codegen; \ # Blackfire CLI curl -fsSL "https://packages.blackfire.io/binaries/blackfire-agent/${BLACKFIRE_VERSION}/blackfire-cli-linux_static_amd64" -o /usr/local/bin/blackfire; \ # Platform.sh CLI curl -fsSL "https://github.com/platformsh/platformsh-cli/releases/download/v${PLATFORMSH_CLI_VERSION}/platform.phar" -o /usr/local/bin/platform; \ # Make all downloaded binaries executable in one shot - (cd /usr/local/bin && chmod +x composer drush8 drush drupal wp mg2-codegen blackfire platform); + (cd /usr/local/bin && chmod +x composer drush8 drush drupal wp blackfire platform); # Node.js ENV NODE_VERSION=8.x @@ -286,6 +283,7 @@ ARG HOME=/home/docker # PHP tools (installed as user) ENV PATH=$PATH:$HOME/.composer/vendor/bin \ + MG_CODEGEN_VERSION=1.10 \ TERMINUS_VERSION=1.8.1 RUN set -xe; \ \ @@ -299,6 +297,8 @@ RUN set -xe; \ # Drupal Coder w/ a matching version of PHP_CodeSniffer cgr drupal/coder >/dev/null; \ phpcs --config-set installed_paths $HOME/.composer/vendor/drupal/coder/coder_sniffer; \ + # Magento2 Code Generator + cgr staempfli/magento2-code-generator:${MG_CODEGEN_VERSION} >/dev/null; \ # Terminus cgr pantheon-systems/terminus:${TERMINUS_VERSION} >/dev/null; \ # Cleanup diff --git a/7.0/Dockerfile b/7.0/Dockerfile index 34b91529..e6279ee3 100644 --- a/7.0/Dockerfile +++ b/7.0/Dockerfile @@ -234,7 +234,6 @@ ENV COMPOSER_VERSION=1.6.3 \ DRUSH_LAUNCHER_FALLBACK=/usr/local/bin/drush8 \ DRUPAL_CONSOLE_VERSION=1.7.0 \ WPCLI_VERSION=1.5.0 \ - MG_CODEGEN_VERSION=1.10 \ BLACKFIRE_VERSION=1.15.0 \ PLATFORMSH_CLI_VERSION=3.33.5 RUN set -xe; \ @@ -248,14 +247,12 @@ RUN set -xe; \ curl -fsSL "https://github.com/hechoendrupal/drupal-console-launcher/releases/download/${DRUPAL_CONSOLE_VERSION}/drupal.phar" -o /usr/local/bin/drupal; \ # Wordpress CLI curl -fsSL "https://github.com/wp-cli/wp-cli/releases/download/v${WPCLI_VERSION}/wp-cli-${WPCLI_VERSION}.phar" -o /usr/local/bin/wp; \ - # Magento2 Code Generator - curl -fsSL "https://github.com/staempfli/magento2-code-generator/releases/download/${MG_CODEGEN_VERSION}/mg2-codegen.phar" -o /usr/local/bin/mg2-codegen; \ # Blackfire CLI curl -fsSL "https://packages.blackfire.io/binaries/blackfire-agent/${BLACKFIRE_VERSION}/blackfire-cli-linux_static_amd64" -o /usr/local/bin/blackfire; \ # Platform.sh CLI curl -fsSL "https://github.com/platformsh/platformsh-cli/releases/download/v${PLATFORMSH_CLI_VERSION}/platform.phar" -o /usr/local/bin/platform; \ # Make all downloaded binaries executable in one shot - (cd /usr/local/bin && chmod +x composer drush8 drush drupal wp mg2-codegen blackfire platform); + (cd /usr/local/bin && chmod +x composer drush8 drush drupal wp blackfire platform); # Node.js ENV NODE_VERSION=8.x @@ -294,6 +291,7 @@ ARG HOME=/home/docker # PHP tools (installed as user) ENV PATH=$PATH:$HOME/.composer/vendor/bin \ + MG_CODEGEN_VERSION=1.10 \ TERMINUS_VERSION=1.8.1 RUN set -xe; \ \ @@ -307,6 +305,8 @@ RUN set -xe; \ # Drupal Coder w/ a matching version of PHP_CodeSniffer cgr drupal/coder >/dev/null; \ phpcs --config-set installed_paths $HOME/.composer/vendor/drupal/coder/coder_sniffer; \ + # Magento2 Code Generator + cgr staempfli/magento2-code-generator:${MG_CODEGEN_VERSION} >/dev/null; \ # Terminus cgr pantheon-systems/terminus:${TERMINUS_VERSION} >/dev/null; \ # Cleanup diff --git a/7.1/Dockerfile b/7.1/Dockerfile index 28b526e9..b001ba84 100644 --- a/7.1/Dockerfile +++ b/7.1/Dockerfile @@ -234,7 +234,6 @@ ENV COMPOSER_VERSION=1.6.3 \ DRUSH_LAUNCHER_FALLBACK=/usr/local/bin/drush8 \ DRUPAL_CONSOLE_VERSION=1.7.0 \ WPCLI_VERSION=1.5.0 \ - MG_CODEGEN_VERSION=1.10 \ BLACKFIRE_VERSION=1.15.0 \ PLATFORMSH_CLI_VERSION=3.33.5 RUN set -xe; \ @@ -248,14 +247,12 @@ RUN set -xe; \ curl -fsSL "https://github.com/hechoendrupal/drupal-console-launcher/releases/download/${DRUPAL_CONSOLE_VERSION}/drupal.phar" -o /usr/local/bin/drupal; \ # Wordpress CLI curl -fsSL "https://github.com/wp-cli/wp-cli/releases/download/v${WPCLI_VERSION}/wp-cli-${WPCLI_VERSION}.phar" -o /usr/local/bin/wp; \ - # Magento2 Code Generator - curl -fsSL "https://github.com/staempfli/magento2-code-generator/releases/download/${MG_CODEGEN_VERSION}/mg2-codegen.phar" -o /usr/local/bin/mg2-codegen; \ # Blackfire CLI curl -fsSL "https://packages.blackfire.io/binaries/blackfire-agent/${BLACKFIRE_VERSION}/blackfire-cli-linux_static_amd64" -o /usr/local/bin/blackfire; \ # Platform.sh CLI curl -fsSL "https://github.com/platformsh/platformsh-cli/releases/download/v${PLATFORMSH_CLI_VERSION}/platform.phar" -o /usr/local/bin/platform; \ # Make all downloaded binaries executable in one shot - (cd /usr/local/bin && chmod +x composer drush8 drush drupal wp mg2-codegen blackfire platform); + (cd /usr/local/bin && chmod +x composer drush8 drush drupal wp blackfire platform); # Node.js ENV NODE_VERSION=8.x @@ -294,6 +291,7 @@ ARG HOME=/home/docker # PHP tools (installed as user) ENV PATH=$PATH:$HOME/.composer/vendor/bin \ + MG_CODEGEN_VERSION=1.10 \ TERMINUS_VERSION=1.8.1 RUN set -xe; \ \ @@ -307,6 +305,8 @@ RUN set -xe; \ # Drupal Coder w/ a matching version of PHP_CodeSniffer cgr drupal/coder >/dev/null; \ phpcs --config-set installed_paths $HOME/.composer/vendor/drupal/coder/coder_sniffer; \ + # Magento2 Code Generator + cgr staempfli/magento2-code-generator:${MG_CODEGEN_VERSION} >/dev/null; \ # Terminus cgr pantheon-systems/terminus:${TERMINUS_VERSION} >/dev/null; \ # Cleanup diff --git a/7.2/Dockerfile b/7.2/Dockerfile index 176192e6..379fc0c5 100644 --- a/7.2/Dockerfile +++ b/7.2/Dockerfile @@ -236,7 +236,6 @@ ENV COMPOSER_VERSION=1.6.3 \ DRUSH_LAUNCHER_FALLBACK=/usr/local/bin/drush8 \ DRUPAL_CONSOLE_VERSION=1.7.0 \ WPCLI_VERSION=1.5.0 \ - MG_CODEGEN_VERSION=1.10 \ BLACKFIRE_VERSION=1.15.0 \ PLATFORMSH_CLI_VERSION=3.33.5 RUN set -xe; \ @@ -250,14 +249,12 @@ RUN set -xe; \ curl -fsSL "https://github.com/hechoendrupal/drupal-console-launcher/releases/download/${DRUPAL_CONSOLE_VERSION}/drupal.phar" -o /usr/local/bin/drupal; \ # Wordpress CLI curl -fsSL "https://github.com/wp-cli/wp-cli/releases/download/v${WPCLI_VERSION}/wp-cli-${WPCLI_VERSION}.phar" -o /usr/local/bin/wp; \ - # Magento2 Code Generator - curl -fsSL "https://github.com/staempfli/magento2-code-generator/releases/download/${MG_CODEGEN_VERSION}/mg2-codegen.phar" -o /usr/local/bin/mg2-codegen; \ # Blackfire CLI curl -fsSL "https://packages.blackfire.io/binaries/blackfire-agent/${BLACKFIRE_VERSION}/blackfire-cli-linux_static_amd64" -o /usr/local/bin/blackfire; \ # Platform.sh CLI curl -fsSL "https://github.com/platformsh/platformsh-cli/releases/download/v${PLATFORMSH_CLI_VERSION}/platform.phar" -o /usr/local/bin/platform; \ # Make all downloaded binaries executable in one shot - (cd /usr/local/bin && chmod +x composer drush8 drush drupal wp mg2-codegen blackfire platform); + (cd /usr/local/bin && chmod +x composer drush8 drush drupal wp blackfire platform); # Node.js ENV NODE_VERSION=8.x @@ -296,6 +293,7 @@ ARG HOME=/home/docker # PHP tools (installed as user) ENV PATH=$PATH:$HOME/.composer/vendor/bin \ + MG_CODEGEN_VERSION=1.10 \ TERMINUS_VERSION=1.8.1 RUN set -xe; \ \ @@ -309,6 +307,8 @@ RUN set -xe; \ # Drupal Coder w/ a matching version of PHP_CodeSniffer cgr drupal/coder >/dev/null; \ phpcs --config-set installed_paths $HOME/.composer/vendor/drupal/coder/coder_sniffer; \ + # Magento2 Code Generator + cgr staempfli/magento2-code-generator:${MG_CODEGEN_VERSION} >/dev/null; \ # Terminus cgr pantheon-systems/terminus:${TERMINUS_VERSION} >/dev/null; \ # Cleanup diff --git a/tests/test.bats b/tests/test.bats index 5a69d9f2..25096bf4 100755 --- a/tests/test.bats +++ b/tests/test.bats @@ -194,9 +194,10 @@ _healthcheck_wait () unset output # Check Magento 2 Code Generator version - # TODO: this should not require running with sudo - sudo should be removed ones the following issues is addressed: - # https://github.com/staempfli/magento2-code-generator/issues/11 - run docker exec -u docker "$NAME" bash -c 'sudo mg2-codegen --version | grep "^mg2-codegen ${MG_CODEGEN_VERSION}$"' + # TODO: this needs to be replaced with the actual version check + # See https://github.com/staempfli/magento2-code-generator/issues/15 + #run docker exec -u docker "$NAME" bash -c 'mg2-codegen --version | grep "^mg2-codegen ${MG_CODEGEN_VERSION}$"' + run docker exec -u docker "$NAME" bash -c 'mg2-codegen --version | grep "^mg2-codegen @git-version@$"' [[ ${status} == 0 ]] unset output From 0c913a2ad9566b978a5533fd46474b32534af8c6 Mon Sep 17 00:00:00 2001 From: Leonid Makarov Date: Fri, 6 Jul 2018 21:12:03 -0700 Subject: [PATCH 28/45] DRUPAL_CONSOLE_VERSION => DRUPAL_CONSOLE_LAUNCHER_VERSION --- 5.6/Dockerfile | 8 ++++---- 7.0/Dockerfile | 8 ++++---- 7.1/Dockerfile | 8 ++++---- 7.2/Dockerfile | 8 ++++---- tests/test.bats | 2 +- 5 files changed, 17 insertions(+), 17 deletions(-) diff --git a/5.6/Dockerfile b/5.6/Dockerfile index a418fda9..cc476150 100644 --- a/5.6/Dockerfile +++ b/5.6/Dockerfile @@ -224,19 +224,19 @@ ENV COMPOSER_VERSION=1.6.3 \ DRUSH_VERSION=8.1.16 \ DRUSH_LAUNCHER_VERSION=0.6.0 \ DRUSH_LAUNCHER_FALLBACK=/usr/local/bin/drush8 \ - DRUPAL_CONSOLE_VERSION=1.7.0 \ + DRUPAL_CONSOLE_LAUNCHER_VERSION=1.7.0 \ WPCLI_VERSION=1.5.0 \ BLACKFIRE_VERSION=1.15.0 \ PLATFORMSH_CLI_VERSION=3.33.5 RUN set -xe; \ # Composer curl -fsSL "https://github.com/composer/composer/releases/download/${COMPOSER_VERSION}/composer.phar" -o /usr/local/bin/composer; \ - # Drush 8 (default) + # Drush 8 (global fallback) curl -fsSL "https://github.com/drush-ops/drush/releases/download/${DRUSH_VERSION}/drush.phar" -o /usr/local/bin/drush8; \ # Drush Launcher curl -fsSL "https://github.com/drush-ops/drush-launcher/releases/download/${DRUSH_LAUNCHER_VERSION}/drush.phar" -o /usr/local/bin/drush; \ - # Drupal Console - curl -fsSL "https://github.com/hechoendrupal/drupal-console-launcher/releases/download/${DRUPAL_CONSOLE_VERSION}/drupal.phar" -o /usr/local/bin/drupal; \ + # Drupal Console Launcher + curl -fsSL "https://github.com/hechoendrupal/drupal-console-launcher/releases/download/${DRUPAL_CONSOLE_LAUNCHER_VERSION}/drupal.phar" -o /usr/local/bin/drupal; \ # Wordpress CLI curl -fsSL "https://github.com/wp-cli/wp-cli/releases/download/v${WPCLI_VERSION}/wp-cli-${WPCLI_VERSION}.phar" -o /usr/local/bin/wp; \ # Blackfire CLI diff --git a/7.0/Dockerfile b/7.0/Dockerfile index e6279ee3..3c4acd41 100644 --- a/7.0/Dockerfile +++ b/7.0/Dockerfile @@ -232,19 +232,19 @@ ENV COMPOSER_VERSION=1.6.3 \ DRUSH_VERSION=8.1.16 \ DRUSH_LAUNCHER_VERSION=0.6.0 \ DRUSH_LAUNCHER_FALLBACK=/usr/local/bin/drush8 \ - DRUPAL_CONSOLE_VERSION=1.7.0 \ + DRUPAL_CONSOLE_LAUNCHER_VERSION=1.7.0 \ WPCLI_VERSION=1.5.0 \ BLACKFIRE_VERSION=1.15.0 \ PLATFORMSH_CLI_VERSION=3.33.5 RUN set -xe; \ # Composer curl -fsSL "https://github.com/composer/composer/releases/download/${COMPOSER_VERSION}/composer.phar" -o /usr/local/bin/composer; \ - # Drush 8 (default) + # Drush 8 (global fallback) curl -fsSL "https://github.com/drush-ops/drush/releases/download/${DRUSH_VERSION}/drush.phar" -o /usr/local/bin/drush8; \ # Drush Launcher curl -fsSL "https://github.com/drush-ops/drush-launcher/releases/download/${DRUSH_LAUNCHER_VERSION}/drush.phar" -o /usr/local/bin/drush; \ - # Drupal Console - curl -fsSL "https://github.com/hechoendrupal/drupal-console-launcher/releases/download/${DRUPAL_CONSOLE_VERSION}/drupal.phar" -o /usr/local/bin/drupal; \ + # Drupal Console Launcher + curl -fsSL "https://github.com/hechoendrupal/drupal-console-launcher/releases/download/${DRUPAL_CONSOLE_LAUNCHER_VERSION}/drupal.phar" -o /usr/local/bin/drupal; \ # Wordpress CLI curl -fsSL "https://github.com/wp-cli/wp-cli/releases/download/v${WPCLI_VERSION}/wp-cli-${WPCLI_VERSION}.phar" -o /usr/local/bin/wp; \ # Blackfire CLI diff --git a/7.1/Dockerfile b/7.1/Dockerfile index b001ba84..d078303d 100644 --- a/7.1/Dockerfile +++ b/7.1/Dockerfile @@ -232,19 +232,19 @@ ENV COMPOSER_VERSION=1.6.3 \ DRUSH_VERSION=8.1.16 \ DRUSH_LAUNCHER_VERSION=0.6.0 \ DRUSH_LAUNCHER_FALLBACK=/usr/local/bin/drush8 \ - DRUPAL_CONSOLE_VERSION=1.7.0 \ + DRUPAL_CONSOLE_LAUNCHER_VERSION=1.7.0 \ WPCLI_VERSION=1.5.0 \ BLACKFIRE_VERSION=1.15.0 \ PLATFORMSH_CLI_VERSION=3.33.5 RUN set -xe; \ # Composer curl -fsSL "https://github.com/composer/composer/releases/download/${COMPOSER_VERSION}/composer.phar" -o /usr/local/bin/composer; \ - # Drush 8 (default) + # Drush 8 (global fallback) curl -fsSL "https://github.com/drush-ops/drush/releases/download/${DRUSH_VERSION}/drush.phar" -o /usr/local/bin/drush8; \ # Drush Launcher curl -fsSL "https://github.com/drush-ops/drush-launcher/releases/download/${DRUSH_LAUNCHER_VERSION}/drush.phar" -o /usr/local/bin/drush; \ - # Drupal Console - curl -fsSL "https://github.com/hechoendrupal/drupal-console-launcher/releases/download/${DRUPAL_CONSOLE_VERSION}/drupal.phar" -o /usr/local/bin/drupal; \ + # Drupal Console Launcher + curl -fsSL "https://github.com/hechoendrupal/drupal-console-launcher/releases/download/${DRUPAL_CONSOLE_LAUNCHER_VERSION}/drupal.phar" -o /usr/local/bin/drupal; \ # Wordpress CLI curl -fsSL "https://github.com/wp-cli/wp-cli/releases/download/v${WPCLI_VERSION}/wp-cli-${WPCLI_VERSION}.phar" -o /usr/local/bin/wp; \ # Blackfire CLI diff --git a/7.2/Dockerfile b/7.2/Dockerfile index 379fc0c5..27df80b4 100644 --- a/7.2/Dockerfile +++ b/7.2/Dockerfile @@ -234,19 +234,19 @@ ENV COMPOSER_VERSION=1.6.3 \ DRUSH_VERSION=8.1.16 \ DRUSH_LAUNCHER_VERSION=0.6.0 \ DRUSH_LAUNCHER_FALLBACK=/usr/local/bin/drush8 \ - DRUPAL_CONSOLE_VERSION=1.7.0 \ + DRUPAL_CONSOLE_LAUNCHER_VERSION=1.7.0 \ WPCLI_VERSION=1.5.0 \ BLACKFIRE_VERSION=1.15.0 \ PLATFORMSH_CLI_VERSION=3.33.5 RUN set -xe; \ # Composer curl -fsSL "https://github.com/composer/composer/releases/download/${COMPOSER_VERSION}/composer.phar" -o /usr/local/bin/composer; \ - # Drush 8 (default) + # Drush 8 (global fallback) curl -fsSL "https://github.com/drush-ops/drush/releases/download/${DRUSH_VERSION}/drush.phar" -o /usr/local/bin/drush8; \ # Drush Launcher curl -fsSL "https://github.com/drush-ops/drush-launcher/releases/download/${DRUSH_LAUNCHER_VERSION}/drush.phar" -o /usr/local/bin/drush; \ - # Drupal Console - curl -fsSL "https://github.com/hechoendrupal/drupal-console-launcher/releases/download/${DRUPAL_CONSOLE_VERSION}/drupal.phar" -o /usr/local/bin/drupal; \ + # Drupal Console Launcher + curl -fsSL "https://github.com/hechoendrupal/drupal-console-launcher/releases/download/${DRUPAL_CONSOLE_LAUNCHER_VERSION}/drupal.phar" -o /usr/local/bin/drupal; \ # Wordpress CLI curl -fsSL "https://github.com/wp-cli/wp-cli/releases/download/v${WPCLI_VERSION}/wp-cli-${WPCLI_VERSION}.phar" -o /usr/local/bin/wp; \ # Blackfire CLI diff --git a/tests/test.bats b/tests/test.bats index 25096bf4..aea19443 100755 --- a/tests/test.bats +++ b/tests/test.bats @@ -184,7 +184,7 @@ _healthcheck_wait () unset output # Check Drupal Console version - run docker exec -u docker "$NAME" bash -c 'drupal --version | grep "^Drupal Console Launcher ${DRUPAL_CONSOLE_VERSION}$"' + run docker exec -u docker "$NAME" bash -c 'drupal --version | grep "^Drupal Console Launcher ${DRUPAL_CONSOLE_LAUNCHER_VERSION}$"' [[ ${status} == 0 ]] unset output From 39d55606b4ff50c5a18ed5921c8899af01840b34 Mon Sep 17 00:00:00 2001 From: Sean Dietrich Date: Mon, 9 Jul 2018 10:50:34 -0700 Subject: [PATCH 29/45] Fixed issue with calling docker-push Docker push script isn't being ran as travis cannot find the docker-push.sh script --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index d5ddeab7..d21c5488 100644 --- a/.travis.yml +++ b/.travis.yml @@ -33,7 +33,7 @@ script: after_success: - docker image ls - - scripts/docker-push.sh + - ${TRAVIS_BUILD_DIR}/scripts/docker-push.sh after_failure: - cd ${TRAVIS_BUILD_DIR}/${VERSION} && make logs From b6096c490fa422534fc865834dc280de41832169 Mon Sep 17 00:00:00 2001 From: Sean Dietrich Date: Mon, 9 Jul 2018 11:53:38 -0700 Subject: [PATCH 30/45] Fixed is_pr function Checked to confirm that TRAVIS_PULL_REQUEST is not false --- scripts/docker-push.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/docker-push.sh b/scripts/docker-push.sh index 2a4278fd..623b51ec 100755 --- a/scripts/docker-push.sh +++ b/scripts/docker-push.sh @@ -20,7 +20,7 @@ is_release () # Check whether the current build is for a pull request is_pr () { - [[ "${TRAVIS_PULL_REQUEST}" == "false" ]] + [[ "${TRAVIS_PULL_REQUEST}" != "false" ]] } is_latest () From 2ef7312825d03955e8b0929cc68a746b8c5899c4 Mon Sep 17 00:00:00 2001 From: Leonid Makarov Date: Wed, 11 Jul 2018 01:38:59 -0700 Subject: [PATCH 31/45] Secrets refactoring - Refactored convert_secrets to use /etc/profile.d/secrets.sh to make variables available for all users/sessions. ~/.bashrc is only used for interactive sessions (has no effect for non-interactive sessions). For login sessions (bash -l), ~/.profile and /etc/profile are used, so we should use bash -lc / bash -ilc instead of bash -c / bash -ic. - Fixed secrets injection and tests for Platform.sh and Pantheon --- 5.6/Makefile | 24 ++++++++++++----- 5.6/startup.sh | 47 +++++++++++++++++++++----------- 7.0/Makefile | 24 ++++++++++++----- 7.0/startup.sh | 47 +++++++++++++++++++++----------- 7.1/Makefile | 24 ++++++++++++----- 7.1/startup.sh | 47 +++++++++++++++++++++----------- 7.2/Makefile | 24 ++++++++++++----- 7.2/startup.sh | 47 +++++++++++++++++++++----------- tests/env_make | 13 +++++++++ tests/test.bats | 71 +++++++++++++++++++++++++------------------------ 10 files changed, 241 insertions(+), 127 deletions(-) create mode 100644 tests/env_make diff --git a/5.6/Makefile b/5.6/Makefile index 24c7e6f9..4f63dac3 100644 --- a/5.6/Makefile +++ b/5.6/Makefile @@ -1,9 +1,11 @@ +-include ../tests/env_make -include env_make VERSION ?= 5.6 REPO = docksal/cli TAG = build-$(VERSION) NAME = docksal-cli-$(VERSION) +CWD = $(shell pwd) # Improve write performance for /home/docker by turning it into a volume VOLUMES += -v /home/docker @@ -19,17 +21,22 @@ test: push: docker push $(REPO):$(TAG) -shell: - docker run --rm --name $(NAME) -it $(PORTS) $(VOLUMES) $(ENV) $(REPO):$(TAG) /bin/bash - -run: +run: clean docker run --rm --name $(NAME) -it $(PORTS) $(VOLUMES) $(ENV) $(REPO):$(TAG) -start: +start: clean docker run -d --name $(NAME) $(PORTS) $(VOLUMES) $(ENV) $(REPO):$(TAG) +# Non-interactive and non-tty docker exec (uses LF instead of CRLF line endings) exec: - docker exec -it $(NAME) /bin/bash + @docker exec -u docker $(NAME) bash -lc "$(CMD)" + +# Interactive docker exec +exec-it: + @docker exec -u docker -it $(NAME) bash -ilc "$(CMD)" + +shell: + @docker exec -u docker -it $(NAME) bash stop: docker stop $(NAME) @@ -37,8 +44,11 @@ stop: logs: docker logs $(NAME) +logs-follow: + docker logs -f $(NAME) + clean: - docker rm -f $(NAME) + docker rm -vf $(NAME) >/dev/null 2>&1 || true release: build make push -e TAG=$(TAG) diff --git a/5.6/startup.sh b/5.6/startup.sh index 79b7cb84..cea49031 100755 --- a/5.6/startup.sh +++ b/5.6/startup.sh @@ -44,23 +44,39 @@ render_tmpl () } # Helper function to loop through all environment variables prefixed with SECRET_ and -# convert to the equivalent variable without SECRET. (ex SECRET_TERMINUS_TOKEN has a variable -# called TERMINUS_TOKEN. +# convert to the equivalent variable without SECRET. +# Example: SECRET_TERMINUS_TOKEN => TERMINUS_TOKEN. convert_secrets () { eval 'secrets=(${!SECRET_@})' - for secret_key in "${secrets[@]}" - do - secret_value=${!secret_key} + for secret_key in "${secrets[@]}"; do key=${secret_key#SECRET_} - echo "export ${key}=\"${secret_value}\";" | sudo -u docker tee -a ~/.docksalrc + secret_value=${!secret_key} + + # Write new variables to /etc/profile.d/secrets.sh to make them available for all users/sessions + echo "export ${key}=\"${secret_value}\"" | tee -a "/etc/profile.d/secrets.sh" >/dev/null + + # Also export new variables here + # This makes them available in the server/php-fpm environment + eval "export ${key}=${secret_value}" done } +# Pantheon authentication terminus_login () { echo-debug "Authenticating with Pantheon..." - terminus auth:login --machine-token="$SECRET_TERMINUS_TOKEN" >/dev/null 2>&1 + # This has to be done using the docker user via su to load the user environment + # Note: 'su -' = 'su -l' = 'su --login' + local output + output=$(sudo su - docker -c "terminus auth:login --machine-token='${TERMINUS_TOKEN}'" 2>&1) + #>/dev/null 2>&1 + if [[ $? != 0 ]]; then + echo-debug "ERROR: Pantheon authentication failed." + echo + echo "$output" + echo + fi } # Process templates @@ -70,15 +86,9 @@ chmod 0600 "$HOME_DIR/.ssh/id_rsa" # Acquia Cloud API config render_tmpl "$HOME_DIR/.acquia/cloudapi.conf" -# Terminus authentication -[[ "$SECRET_TERMINUS_TOKEN" ]] && terminus_login - # Convert all Environment Variables Prefixed with SECRET_ convert_secrets -# Source Docksalrc for when someone runs bash in the container -echo "source ~/.docksalrc" | sudo -u docker tee -a ~/.bashrc - # Docker user uid/gid mapping to the host user uid/gid [[ "$HOST_UID" != "" ]] && [[ "$HOST_GID" != "" ]] && uid_gid_reset @@ -93,15 +103,20 @@ chown "${HOST_UID-:1000}:${HOST_GID:-1000}" -R "$HOME_DIR" # We apply a fix/workaround for this at startup (non-recursive). chown "${HOST_UID-:1000}:${HOST_GID:-1000}" /var/www -# Initialization steps completed. Create a pid file to mark the container as healthy -echo-debug "Preliminary initialization completed" -touch /var/run/cli +# Automatically authenticate with Pantheon in Terminus token is present +# Note: this has to happen after th home directory permissions are reset, +# otherwise the docker user may not have write access to /home/.terminus, where the auth session data is stored. +[[ "$TERMINUS_TOKEN" != "" ]] && terminus_login # If crontab file is found within project add contents to user crontab file. if [[ -f ${PROJECT_ROOT}/.docksal/services/cli/crontab ]]; then cat ${PROJECT_ROOT}/.docksal/services/cli/crontab | crontab -u docker - fi +# Initialization steps completed. Create a pid file to mark the container as healthy +echo-debug "Preliminary initialization completed." +touch /var/run/cli + if [[ -x ${PROJECT_ROOT}/.docksal/services/cli/startup.sh ]]; then echo-debug "Running Custom Startup Script..." ${PROJECT_ROOT}/.docksal/services/cli/startup.sh diff --git a/7.0/Makefile b/7.0/Makefile index 683dca13..e9d5b1b9 100644 --- a/7.0/Makefile +++ b/7.0/Makefile @@ -1,9 +1,11 @@ +-include ../tests/env_make -include env_make VERSION ?= 7.0 REPO = docksal/cli TAG = build-$(VERSION) NAME = docksal-cli-$(VERSION) +CWD = $(shell pwd) # Improve write performance for /home/docker by turning it into a volume VOLUMES += -v /home/docker @@ -19,17 +21,22 @@ test: push: docker push $(REPO):$(TAG) -shell: - docker run --rm --name $(NAME) -it $(PORTS) $(VOLUMES) $(ENV) $(REPO):$(TAG) /bin/bash - -run: +run: clean docker run --rm --name $(NAME) -it $(PORTS) $(VOLUMES) $(ENV) $(REPO):$(TAG) -start: +start: clean docker run -d --name $(NAME) $(PORTS) $(VOLUMES) $(ENV) $(REPO):$(TAG) +# Non-interactive and non-tty docker exec (uses LF instead of CRLF line endings) exec: - docker exec -it $(NAME) /bin/bash + @docker exec -u docker $(NAME) bash -lc "$(CMD)" + +# Interactive docker exec +exec-it: + @docker exec -u docker -it $(NAME) bash -ilc "$(CMD)" + +shell: + @docker exec -u docker -it $(NAME) bash stop: docker stop $(NAME) @@ -37,8 +44,11 @@ stop: logs: docker logs $(NAME) +logs-follow: + docker logs -f $(NAME) + clean: - docker rm -f $(NAME) + docker rm -vf $(NAME) >/dev/null 2>&1 || true release: build make push -e TAG=$(TAG) diff --git a/7.0/startup.sh b/7.0/startup.sh index 79b7cb84..cea49031 100755 --- a/7.0/startup.sh +++ b/7.0/startup.sh @@ -44,23 +44,39 @@ render_tmpl () } # Helper function to loop through all environment variables prefixed with SECRET_ and -# convert to the equivalent variable without SECRET. (ex SECRET_TERMINUS_TOKEN has a variable -# called TERMINUS_TOKEN. +# convert to the equivalent variable without SECRET. +# Example: SECRET_TERMINUS_TOKEN => TERMINUS_TOKEN. convert_secrets () { eval 'secrets=(${!SECRET_@})' - for secret_key in "${secrets[@]}" - do - secret_value=${!secret_key} + for secret_key in "${secrets[@]}"; do key=${secret_key#SECRET_} - echo "export ${key}=\"${secret_value}\";" | sudo -u docker tee -a ~/.docksalrc + secret_value=${!secret_key} + + # Write new variables to /etc/profile.d/secrets.sh to make them available for all users/sessions + echo "export ${key}=\"${secret_value}\"" | tee -a "/etc/profile.d/secrets.sh" >/dev/null + + # Also export new variables here + # This makes them available in the server/php-fpm environment + eval "export ${key}=${secret_value}" done } +# Pantheon authentication terminus_login () { echo-debug "Authenticating with Pantheon..." - terminus auth:login --machine-token="$SECRET_TERMINUS_TOKEN" >/dev/null 2>&1 + # This has to be done using the docker user via su to load the user environment + # Note: 'su -' = 'su -l' = 'su --login' + local output + output=$(sudo su - docker -c "terminus auth:login --machine-token='${TERMINUS_TOKEN}'" 2>&1) + #>/dev/null 2>&1 + if [[ $? != 0 ]]; then + echo-debug "ERROR: Pantheon authentication failed." + echo + echo "$output" + echo + fi } # Process templates @@ -70,15 +86,9 @@ chmod 0600 "$HOME_DIR/.ssh/id_rsa" # Acquia Cloud API config render_tmpl "$HOME_DIR/.acquia/cloudapi.conf" -# Terminus authentication -[[ "$SECRET_TERMINUS_TOKEN" ]] && terminus_login - # Convert all Environment Variables Prefixed with SECRET_ convert_secrets -# Source Docksalrc for when someone runs bash in the container -echo "source ~/.docksalrc" | sudo -u docker tee -a ~/.bashrc - # Docker user uid/gid mapping to the host user uid/gid [[ "$HOST_UID" != "" ]] && [[ "$HOST_GID" != "" ]] && uid_gid_reset @@ -93,15 +103,20 @@ chown "${HOST_UID-:1000}:${HOST_GID:-1000}" -R "$HOME_DIR" # We apply a fix/workaround for this at startup (non-recursive). chown "${HOST_UID-:1000}:${HOST_GID:-1000}" /var/www -# Initialization steps completed. Create a pid file to mark the container as healthy -echo-debug "Preliminary initialization completed" -touch /var/run/cli +# Automatically authenticate with Pantheon in Terminus token is present +# Note: this has to happen after th home directory permissions are reset, +# otherwise the docker user may not have write access to /home/.terminus, where the auth session data is stored. +[[ "$TERMINUS_TOKEN" != "" ]] && terminus_login # If crontab file is found within project add contents to user crontab file. if [[ -f ${PROJECT_ROOT}/.docksal/services/cli/crontab ]]; then cat ${PROJECT_ROOT}/.docksal/services/cli/crontab | crontab -u docker - fi +# Initialization steps completed. Create a pid file to mark the container as healthy +echo-debug "Preliminary initialization completed." +touch /var/run/cli + if [[ -x ${PROJECT_ROOT}/.docksal/services/cli/startup.sh ]]; then echo-debug "Running Custom Startup Script..." ${PROJECT_ROOT}/.docksal/services/cli/startup.sh diff --git a/7.1/Makefile b/7.1/Makefile index 9a906417..d7738dc1 100644 --- a/7.1/Makefile +++ b/7.1/Makefile @@ -1,9 +1,11 @@ +-include ../tests/env_make -include env_make VERSION ?= 7.1 REPO = docksal/cli TAG = build-$(VERSION) NAME = docksal-cli-$(VERSION) +CWD = $(shell pwd) # Improve write performance for /home/docker by turning it into a volume VOLUMES += -v /home/docker @@ -19,17 +21,22 @@ test: push: docker push $(REPO):$(TAG) -shell: - docker run --rm --name $(NAME) -it $(PORTS) $(VOLUMES) $(ENV) $(REPO):$(TAG) /bin/bash - -run: +run: clean docker run --rm --name $(NAME) -it $(PORTS) $(VOLUMES) $(ENV) $(REPO):$(TAG) -start: +start: clean docker run -d --name $(NAME) $(PORTS) $(VOLUMES) $(ENV) $(REPO):$(TAG) +# Non-interactive and non-tty docker exec (uses LF instead of CRLF line endings) exec: - docker exec -it $(NAME) /bin/bash + @docker exec -u docker $(NAME) bash -lc "$(CMD)" + +# Interactive docker exec +exec-it: + @docker exec -u docker -it $(NAME) bash -ilc "$(CMD)" + +shell: + @docker exec -u docker -it $(NAME) bash stop: docker stop $(NAME) @@ -37,8 +44,11 @@ stop: logs: docker logs $(NAME) +logs-follow: + docker logs -f $(NAME) + clean: - docker rm -f $(NAME) + docker rm -vf $(NAME) >/dev/null 2>&1 || true release: build make push -e TAG=$(TAG) diff --git a/7.1/startup.sh b/7.1/startup.sh index 79b7cb84..cea49031 100755 --- a/7.1/startup.sh +++ b/7.1/startup.sh @@ -44,23 +44,39 @@ render_tmpl () } # Helper function to loop through all environment variables prefixed with SECRET_ and -# convert to the equivalent variable without SECRET. (ex SECRET_TERMINUS_TOKEN has a variable -# called TERMINUS_TOKEN. +# convert to the equivalent variable without SECRET. +# Example: SECRET_TERMINUS_TOKEN => TERMINUS_TOKEN. convert_secrets () { eval 'secrets=(${!SECRET_@})' - for secret_key in "${secrets[@]}" - do - secret_value=${!secret_key} + for secret_key in "${secrets[@]}"; do key=${secret_key#SECRET_} - echo "export ${key}=\"${secret_value}\";" | sudo -u docker tee -a ~/.docksalrc + secret_value=${!secret_key} + + # Write new variables to /etc/profile.d/secrets.sh to make them available for all users/sessions + echo "export ${key}=\"${secret_value}\"" | tee -a "/etc/profile.d/secrets.sh" >/dev/null + + # Also export new variables here + # This makes them available in the server/php-fpm environment + eval "export ${key}=${secret_value}" done } +# Pantheon authentication terminus_login () { echo-debug "Authenticating with Pantheon..." - terminus auth:login --machine-token="$SECRET_TERMINUS_TOKEN" >/dev/null 2>&1 + # This has to be done using the docker user via su to load the user environment + # Note: 'su -' = 'su -l' = 'su --login' + local output + output=$(sudo su - docker -c "terminus auth:login --machine-token='${TERMINUS_TOKEN}'" 2>&1) + #>/dev/null 2>&1 + if [[ $? != 0 ]]; then + echo-debug "ERROR: Pantheon authentication failed." + echo + echo "$output" + echo + fi } # Process templates @@ -70,15 +86,9 @@ chmod 0600 "$HOME_DIR/.ssh/id_rsa" # Acquia Cloud API config render_tmpl "$HOME_DIR/.acquia/cloudapi.conf" -# Terminus authentication -[[ "$SECRET_TERMINUS_TOKEN" ]] && terminus_login - # Convert all Environment Variables Prefixed with SECRET_ convert_secrets -# Source Docksalrc for when someone runs bash in the container -echo "source ~/.docksalrc" | sudo -u docker tee -a ~/.bashrc - # Docker user uid/gid mapping to the host user uid/gid [[ "$HOST_UID" != "" ]] && [[ "$HOST_GID" != "" ]] && uid_gid_reset @@ -93,15 +103,20 @@ chown "${HOST_UID-:1000}:${HOST_GID:-1000}" -R "$HOME_DIR" # We apply a fix/workaround for this at startup (non-recursive). chown "${HOST_UID-:1000}:${HOST_GID:-1000}" /var/www -# Initialization steps completed. Create a pid file to mark the container as healthy -echo-debug "Preliminary initialization completed" -touch /var/run/cli +# Automatically authenticate with Pantheon in Terminus token is present +# Note: this has to happen after th home directory permissions are reset, +# otherwise the docker user may not have write access to /home/.terminus, where the auth session data is stored. +[[ "$TERMINUS_TOKEN" != "" ]] && terminus_login # If crontab file is found within project add contents to user crontab file. if [[ -f ${PROJECT_ROOT}/.docksal/services/cli/crontab ]]; then cat ${PROJECT_ROOT}/.docksal/services/cli/crontab | crontab -u docker - fi +# Initialization steps completed. Create a pid file to mark the container as healthy +echo-debug "Preliminary initialization completed." +touch /var/run/cli + if [[ -x ${PROJECT_ROOT}/.docksal/services/cli/startup.sh ]]; then echo-debug "Running Custom Startup Script..." ${PROJECT_ROOT}/.docksal/services/cli/startup.sh diff --git a/7.2/Makefile b/7.2/Makefile index 538c0eb9..db924e9f 100644 --- a/7.2/Makefile +++ b/7.2/Makefile @@ -1,9 +1,11 @@ +-include ../tests/env_make -include env_make VERSION ?= 7.2 REPO = docksal/cli TAG = build-$(VERSION) NAME = docksal-cli-$(VERSION) +CWD = $(shell pwd) # Improve write performance for /home/docker by turning it into a volume VOLUMES += -v /home/docker @@ -19,17 +21,22 @@ test: push: docker push $(REPO):$(TAG) -shell: - docker run --rm --name $(NAME) -it $(PORTS) $(VOLUMES) $(ENV) $(REPO):$(TAG) /bin/bash - -run: +run: clean docker run --rm --name $(NAME) -it $(PORTS) $(VOLUMES) $(ENV) $(REPO):$(TAG) -start: +start: clean docker run -d --name $(NAME) $(PORTS) $(VOLUMES) $(ENV) $(REPO):$(TAG) +# Non-interactive and non-tty docker exec (uses LF instead of CRLF line endings) exec: - docker exec -it $(NAME) /bin/bash + @docker exec -u docker $(NAME) bash -lc "$(CMD)" + +# Interactive docker exec +exec-it: + @docker exec -u docker -it $(NAME) bash -ilc "$(CMD)" + +shell: + @docker exec -u docker -it $(NAME) bash stop: docker stop $(NAME) @@ -37,8 +44,11 @@ stop: logs: docker logs $(NAME) +logs-follow: + docker logs -f $(NAME) + clean: - docker rm -f $(NAME) + docker rm -vf $(NAME) >/dev/null 2>&1 || true release: build make push -e TAG=$(TAG) diff --git a/7.2/startup.sh b/7.2/startup.sh index 79b7cb84..cea49031 100755 --- a/7.2/startup.sh +++ b/7.2/startup.sh @@ -44,23 +44,39 @@ render_tmpl () } # Helper function to loop through all environment variables prefixed with SECRET_ and -# convert to the equivalent variable without SECRET. (ex SECRET_TERMINUS_TOKEN has a variable -# called TERMINUS_TOKEN. +# convert to the equivalent variable without SECRET. +# Example: SECRET_TERMINUS_TOKEN => TERMINUS_TOKEN. convert_secrets () { eval 'secrets=(${!SECRET_@})' - for secret_key in "${secrets[@]}" - do - secret_value=${!secret_key} + for secret_key in "${secrets[@]}"; do key=${secret_key#SECRET_} - echo "export ${key}=\"${secret_value}\";" | sudo -u docker tee -a ~/.docksalrc + secret_value=${!secret_key} + + # Write new variables to /etc/profile.d/secrets.sh to make them available for all users/sessions + echo "export ${key}=\"${secret_value}\"" | tee -a "/etc/profile.d/secrets.sh" >/dev/null + + # Also export new variables here + # This makes them available in the server/php-fpm environment + eval "export ${key}=${secret_value}" done } +# Pantheon authentication terminus_login () { echo-debug "Authenticating with Pantheon..." - terminus auth:login --machine-token="$SECRET_TERMINUS_TOKEN" >/dev/null 2>&1 + # This has to be done using the docker user via su to load the user environment + # Note: 'su -' = 'su -l' = 'su --login' + local output + output=$(sudo su - docker -c "terminus auth:login --machine-token='${TERMINUS_TOKEN}'" 2>&1) + #>/dev/null 2>&1 + if [[ $? != 0 ]]; then + echo-debug "ERROR: Pantheon authentication failed." + echo + echo "$output" + echo + fi } # Process templates @@ -70,15 +86,9 @@ chmod 0600 "$HOME_DIR/.ssh/id_rsa" # Acquia Cloud API config render_tmpl "$HOME_DIR/.acquia/cloudapi.conf" -# Terminus authentication -[[ "$SECRET_TERMINUS_TOKEN" ]] && terminus_login - # Convert all Environment Variables Prefixed with SECRET_ convert_secrets -# Source Docksalrc for when someone runs bash in the container -echo "source ~/.docksalrc" | sudo -u docker tee -a ~/.bashrc - # Docker user uid/gid mapping to the host user uid/gid [[ "$HOST_UID" != "" ]] && [[ "$HOST_GID" != "" ]] && uid_gid_reset @@ -93,15 +103,20 @@ chown "${HOST_UID-:1000}:${HOST_GID:-1000}" -R "$HOME_DIR" # We apply a fix/workaround for this at startup (non-recursive). chown "${HOST_UID-:1000}:${HOST_GID:-1000}" /var/www -# Initialization steps completed. Create a pid file to mark the container as healthy -echo-debug "Preliminary initialization completed" -touch /var/run/cli +# Automatically authenticate with Pantheon in Terminus token is present +# Note: this has to happen after th home directory permissions are reset, +# otherwise the docker user may not have write access to /home/.terminus, where the auth session data is stored. +[[ "$TERMINUS_TOKEN" != "" ]] && terminus_login # If crontab file is found within project add contents to user crontab file. if [[ -f ${PROJECT_ROOT}/.docksal/services/cli/crontab ]]; then cat ${PROJECT_ROOT}/.docksal/services/cli/crontab | crontab -u docker - fi +# Initialization steps completed. Create a pid file to mark the container as healthy +echo-debug "Preliminary initialization completed." +touch /var/run/cli + if [[ -x ${PROJECT_ROOT}/.docksal/services/cli/startup.sh ]]; then echo-debug "Running Custom Startup Script..." ${PROJECT_ROOT}/.docksal/services/cli/startup.sh diff --git a/tests/env_make b/tests/env_make new file mode 100644 index 00000000..845e2a55 --- /dev/null +++ b/tests/env_make @@ -0,0 +1,13 @@ +VOLUMES = \ + -v /home/docker \ + -v $(CWD)/../tests:/var/www + +ENV = \ + -e XDEBUG_ENABLED \ + -e SECRET_BLACKFIRE_CLIENT_ID \ + -e SECRET_BLACKFIRE_CLIENT_TOKEN \ + -e SECRET_SSH_PRIVATE_KEY \ + -e SECRET_ACAPI_EMAIL \ + -e SECRET_ACAPI_KEY \ + -e SECRET_PLATFORMSH_CLI_TOKEN \ + -e SECRET_TERMINUS_TOKEN diff --git a/tests/test.bats b/tests/test.bats index aea19443..6aaf7694 100755 --- a/tests/test.bats +++ b/tests/test.bats @@ -277,69 +277,70 @@ _healthcheck_wait () [[ "${output}" =~ "I ran properly" ]] } -@test "Check Platform.sh Integration" { +@test "Check Platform.sh integration" { [[ $SKIP == 1 ]] && skip + # Confirm secret is not empty + [[ "${SECRET_PLATFORMSH_CLI_TOKEN}" != "" ]] + ### Setup ### - docker rm -vf "$NAME" >/dev/null 2>&1 || true - docker run --name "$NAME" -d \ - -v /home/docker \ - -v $(pwd)/../tests:/var/www \ - -e SECRET_PLATFORMSH_CLI_TOKEN \ - "$IMAGE" + make start -e ENV='-e SECRET_PLATFORMSH_CLI_TOKEN' _healthcheck_wait ### Tests ### - # Confirm output is not empty and token is passed to container - run docker exec -it -u docker "$NAME" bash -c 'source $HOME/.docksalrc >/dev/null 2>&1; echo "${SECRET_PLATFORMSH_CLI_TOKEN}"' - [[ "${output}" != "" ]] + # Confirm token was passed to the container + run docker exec -u docker "${NAME}" bash -lc 'echo SECRET_PLATFORMSH_CLI_TOKEN: ${SECRET_PLATFORMSH_CLI_TOKEN}' + [[ "${output}" == "SECRET_PLATFORMSH_CLI_TOKEN: ${SECRET_PLATFORMSH_CLI_TOKEN}" ]] unset output - # Confirm token passed to container was converted without SECRET_ - run fin exec 'echo ${PLATFORMSH_CLI_TOKEN}' - [[ "${output}" != "" ]] + # Confirm the SECRET_ prefix was stripped + run docker exec -u docker "${NAME}" bash -lc 'echo PLATFORMSH_CLI_TOKEN: ${SECRET_PLATFORMSH_CLI_TOKEN}' + [[ "${output}" == "PLATFORMSH_CLI_TOKEN: ${SECRET_PLATFORMSH_CLI_TOKEN}" ]] unset output - # Confirm Authentication - run docker exec -it -u docker "$NAME" bash -c 'source $HOME/.docksalrc >/dev/null 2>&1; platform auth:info -n' - [[ ${status} == 0 ]] && - [[ ! "${output}" =~ "Invalid API token" ]] && - [[ "${output}" =~ "Docksal App" ]] && + # Confirm authentication works + run docker exec -u docker "${NAME}" bash -lc 'platform auth:info -n' + [[ ${status} == 0 ]] + [[ ! "${output}" =~ "Invalid API token" ]] + [[ "${output}" =~ "developer@docksal.io" ]] unset output ### Cleanup ### - docker rm -vf "$NAME" >/dev/null 2>&1 || true + make clean } -@test "Check Pantheon Integration" { +@test "Check Pantheon integration" { [[ $SKIP == 1 ]] && skip + # Confirm secret is not empty + [[ "${SECRET_TERMINUS_TOKEN}" != "" ]] + ### Setup ### - docker rm -vf "$NAME" >/dev/null 2>&1 || true - docker run --name "$NAME" -d \ - -v /home/docker \ - -v $(pwd)/../tests:/var/www \ - -e SECRET_TERMINUS_TOKEN \ - "$IMAGE" + make start -e ENV='-e SECRET_TERMINUS_TOKEN' _healthcheck_wait ### Tests ### - # Confirm output is not empty and token is passed to container - run docker exec -it -u docker "$NAME" bash -c 'source $HOME/.docksalrc >/dev/null 2>&1; echo "${SECRET_TERMINUS_TOKEN}"' - [[ "${output}" =~ "${SECRET_TERMINUS_TOKEN}" ]] + # Confirm token was passed to the container + run docker exec -u docker "${NAME}" bash -lc 'echo SECRET_TERMINUS_TOKEN: ${SECRET_TERMINUS_TOKEN}' + [[ "${output}" == "SECRET_TERMINUS_TOKEN: ${SECRET_TERMINUS_TOKEN}" ]] unset output - # Confirm Authentication - run docker exec -it -u docker "$NAME" bash -c 'source $HOME/.docksalrc >/dev/null 2>&1; terminus auth:whoami' - [[ ${status} == 0 ]] && - [[ ! "${output}" =~ "You are not logged in." ]] && - [[ "${output}" =~ "developer@docksal.io" ]] && + # Confirm the SECRET_ prefix was stripped + run docker exec -u docker "${NAME}" bash -lc 'echo TERMINUS_TOKEN: ${TERMINUS_TOKEN}' + [[ "${output}" == "TERMINUS_TOKEN: ${SECRET_TERMINUS_TOKEN}" ]] + unset output + + # Confirm authentication works + run docker exec -u docker "${NAME}" bash -lc 'terminus auth:whoami' + [[ ${status} == 0 ]] + [[ ! "${output}" =~ "You are not logged in." ]] + [[ "${output}" =~ "developer@docksal.io" ]] unset output ### Cleanup ### - docker rm -vf "$NAME" >/dev/null 2>&1 || true + make clean } @test "Custom Cron Integration" { From 2b2dbf872a3bfd5ec99a382372f4480bab23d45c Mon Sep 17 00:00:00 2001 From: Leonid Makarov Date: Wed, 11 Jul 2018 01:44:11 -0700 Subject: [PATCH 32/45] Fixed cron - Run cron in foreground (cron -f) under supervisor - Simplified cron test --- 5.6/config/supervisord.conf | 7 ++----- 5.6/startup.sh | 1 + 7.0/config/supervisord.conf | 7 ++----- 7.0/startup.sh | 1 + 7.1/config/supervisord.conf | 7 ++----- 7.1/startup.sh | 1 + 7.2/config/supervisord.conf | 7 ++----- 7.2/startup.sh | 1 + tests/.docksal/services/cli/crontab | 2 +- tests/test.bats | 29 +++++++++-------------------- 10 files changed, 22 insertions(+), 41 deletions(-) diff --git a/5.6/config/supervisord.conf b/5.6/config/supervisord.conf index 574eeff5..4326e8c7 100644 --- a/5.6/config/supervisord.conf +++ b/5.6/config/supervisord.conf @@ -17,8 +17,5 @@ stderr_logfile = /dev/stderr stderr_logfile_maxbytes = 0 [program:cron] -command = /usr/sbin/cron -stdout_logfile = /dev/stdout -stdout_logfile_maxbytes = 0 -stderr_logfile = /dev/stderr -stderr_logfile_maxbytes = 0 +# Cron will only log to syslog and nothing else... +command = /usr/sbin/cron -f diff --git a/5.6/startup.sh b/5.6/startup.sh index cea49031..0f375b2d 100755 --- a/5.6/startup.sh +++ b/5.6/startup.sh @@ -110,6 +110,7 @@ chown "${HOST_UID-:1000}:${HOST_GID:-1000}" /var/www # If crontab file is found within project add contents to user crontab file. if [[ -f ${PROJECT_ROOT}/.docksal/services/cli/crontab ]]; then + echo-debug "Loading crontab..." cat ${PROJECT_ROOT}/.docksal/services/cli/crontab | crontab -u docker - fi diff --git a/7.0/config/supervisord.conf b/7.0/config/supervisord.conf index 574eeff5..4326e8c7 100644 --- a/7.0/config/supervisord.conf +++ b/7.0/config/supervisord.conf @@ -17,8 +17,5 @@ stderr_logfile = /dev/stderr stderr_logfile_maxbytes = 0 [program:cron] -command = /usr/sbin/cron -stdout_logfile = /dev/stdout -stdout_logfile_maxbytes = 0 -stderr_logfile = /dev/stderr -stderr_logfile_maxbytes = 0 +# Cron will only log to syslog and nothing else... +command = /usr/sbin/cron -f diff --git a/7.0/startup.sh b/7.0/startup.sh index cea49031..0f375b2d 100755 --- a/7.0/startup.sh +++ b/7.0/startup.sh @@ -110,6 +110,7 @@ chown "${HOST_UID-:1000}:${HOST_GID:-1000}" /var/www # If crontab file is found within project add contents to user crontab file. if [[ -f ${PROJECT_ROOT}/.docksal/services/cli/crontab ]]; then + echo-debug "Loading crontab..." cat ${PROJECT_ROOT}/.docksal/services/cli/crontab | crontab -u docker - fi diff --git a/7.1/config/supervisord.conf b/7.1/config/supervisord.conf index 574eeff5..4326e8c7 100644 --- a/7.1/config/supervisord.conf +++ b/7.1/config/supervisord.conf @@ -17,8 +17,5 @@ stderr_logfile = /dev/stderr stderr_logfile_maxbytes = 0 [program:cron] -command = /usr/sbin/cron -stdout_logfile = /dev/stdout -stdout_logfile_maxbytes = 0 -stderr_logfile = /dev/stderr -stderr_logfile_maxbytes = 0 +# Cron will only log to syslog and nothing else... +command = /usr/sbin/cron -f diff --git a/7.1/startup.sh b/7.1/startup.sh index cea49031..0f375b2d 100755 --- a/7.1/startup.sh +++ b/7.1/startup.sh @@ -110,6 +110,7 @@ chown "${HOST_UID-:1000}:${HOST_GID:-1000}" /var/www # If crontab file is found within project add contents to user crontab file. if [[ -f ${PROJECT_ROOT}/.docksal/services/cli/crontab ]]; then + echo-debug "Loading crontab..." cat ${PROJECT_ROOT}/.docksal/services/cli/crontab | crontab -u docker - fi diff --git a/7.2/config/supervisord.conf b/7.2/config/supervisord.conf index 574eeff5..4326e8c7 100644 --- a/7.2/config/supervisord.conf +++ b/7.2/config/supervisord.conf @@ -17,8 +17,5 @@ stderr_logfile = /dev/stderr stderr_logfile_maxbytes = 0 [program:cron] -command = /usr/sbin/cron -stdout_logfile = /dev/stdout -stdout_logfile_maxbytes = 0 -stderr_logfile = /dev/stderr -stderr_logfile_maxbytes = 0 +# Cron will only log to syslog and nothing else... +command = /usr/sbin/cron -f diff --git a/7.2/startup.sh b/7.2/startup.sh index cea49031..0f375b2d 100755 --- a/7.2/startup.sh +++ b/7.2/startup.sh @@ -110,6 +110,7 @@ chown "${HOST_UID-:1000}:${HOST_GID:-1000}" /var/www # If crontab file is found within project add contents to user crontab file. if [[ -f ${PROJECT_ROOT}/.docksal/services/cli/crontab ]]; then + echo-debug "Loading crontab..." cat ${PROJECT_ROOT}/.docksal/services/cli/crontab | crontab -u docker - fi diff --git a/tests/.docksal/services/cli/crontab b/tests/.docksal/services/cli/crontab index 82d24cee..389f5c04 100644 --- a/tests/.docksal/services/cli/crontab +++ b/tests/.docksal/services/cli/crontab @@ -1 +1 @@ -* * * * * echo "The current date is $(date)" > /tmp/date.txt +* * * * * echo "The current date is $(date)" >> /tmp/date.txt diff --git a/tests/test.bats b/tests/test.bats index 6aaf7694..82368b12 100755 --- a/tests/test.bats +++ b/tests/test.bats @@ -343,41 +343,30 @@ _healthcheck_wait () make clean } -@test "Custom Cron Integration" { +@test "Check cron" { [[ $SKIP == 1 ]] && skip ### Setup ### - docker rm -vf "$NAME" >/dev/null 2>&1 || true - docker run --name "$NAME" -d \ - -v /home/docker \ - -v $(pwd)/../tests:/var/www \ - "$IMAGE" + make start _healthcheck_wait ### Tests ### # Confirm output from cron is working - # Create tmp date file - docker exec -it -u docker "$NAME" bash -c 'echo "The current date is $(date)" > /tmp/date.txt; chmod 0777 /tmp/date.txt' - - # Confirm File created and exists - run docker exec -it -u docker "$NAME" bash -c 'cat /tmp/date.txt' - [[ "${output}" =~ "The current date is " ]] - OLD_OUTPUT="${output}" + # Create tmp date file and confirm it's empty + docker exec -u docker "$NAME" bash -lc 'touch /tmp/date.txt' + run docker exec -u docker "$NAME" bash -lc 'cat /tmp/date.txt' + [[ "${output}" == "" ]] unset output - # Sleep for 60 Seconds so cron can run again. + # Sleep for 60 seconds so cron can run again. sleep 60 # Confirm cron has ran and file contents has changed - run docker exec -it -u docker "$NAME" bash -c 'cat /tmp/date.txt' + run docker exec -u docker "$NAME" bash -lc 'tail -1 /tmp/date.txt' [[ "${output}" =~ "The current date is " ]] - NEW_OUTPUT="${output}" unset output - # Confirm First Test is not the same as old test - [[ "${OLD_OUTPUT}" != "${NEW_OUTPUT}" ]] - ### Cleanup ### - docker rm -vf "$NAME" >/dev/null 2>&1 || true + make clean } From 1f400bc57854a436e689b066c9f52b017de53c20 Mon Sep 17 00:00:00 2001 From: Leonid Makarov Date: Wed, 11 Jul 2018 01:46:49 -0700 Subject: [PATCH 33/45] Added messaging around custom startup script Also updated tests to use make commands instead of fin --- 5.6/startup.sh | 10 ++++++++-- 7.0/startup.sh | 10 ++++++++-- 7.1/startup.sh | 10 ++++++++-- 7.2/startup.sh | 10 ++++++++-- tests/test.bats | 14 ++++++++------ 5 files changed, 40 insertions(+), 14 deletions(-) diff --git a/5.6/startup.sh b/5.6/startup.sh index 0f375b2d..b066f5ad 100755 --- a/5.6/startup.sh +++ b/5.6/startup.sh @@ -118,10 +118,16 @@ fi echo-debug "Preliminary initialization completed." touch /var/run/cli +# Execute a custom startup script if present if [[ -x ${PROJECT_ROOT}/.docksal/services/cli/startup.sh ]]; then - echo-debug "Running Custom Startup Script..." + echo-debug "Running custom startup script..." + # TODO: should we source the script instead? ${PROJECT_ROOT}/.docksal/services/cli/startup.sh - echo-debug "Custom Startup Script Complete..." + if [[ $? == 0 ]]; then + echo-debug "Custom startup script executed successfully." + else + echo-debug "ERROR: Custom startup script execution failed." + fi fi # Execute passed CMD arguments diff --git a/7.0/startup.sh b/7.0/startup.sh index 0f375b2d..b066f5ad 100755 --- a/7.0/startup.sh +++ b/7.0/startup.sh @@ -118,10 +118,16 @@ fi echo-debug "Preliminary initialization completed." touch /var/run/cli +# Execute a custom startup script if present if [[ -x ${PROJECT_ROOT}/.docksal/services/cli/startup.sh ]]; then - echo-debug "Running Custom Startup Script..." + echo-debug "Running custom startup script..." + # TODO: should we source the script instead? ${PROJECT_ROOT}/.docksal/services/cli/startup.sh - echo-debug "Custom Startup Script Complete..." + if [[ $? == 0 ]]; then + echo-debug "Custom startup script executed successfully." + else + echo-debug "ERROR: Custom startup script execution failed." + fi fi # Execute passed CMD arguments diff --git a/7.1/startup.sh b/7.1/startup.sh index 0f375b2d..b066f5ad 100755 --- a/7.1/startup.sh +++ b/7.1/startup.sh @@ -118,10 +118,16 @@ fi echo-debug "Preliminary initialization completed." touch /var/run/cli +# Execute a custom startup script if present if [[ -x ${PROJECT_ROOT}/.docksal/services/cli/startup.sh ]]; then - echo-debug "Running Custom Startup Script..." + echo-debug "Running custom startup script..." + # TODO: should we source the script instead? ${PROJECT_ROOT}/.docksal/services/cli/startup.sh - echo-debug "Custom Startup Script Complete..." + if [[ $? == 0 ]]; then + echo-debug "Custom startup script executed successfully." + else + echo-debug "ERROR: Custom startup script execution failed." + fi fi # Execute passed CMD arguments diff --git a/7.2/startup.sh b/7.2/startup.sh index 0f375b2d..b066f5ad 100755 --- a/7.2/startup.sh +++ b/7.2/startup.sh @@ -118,10 +118,16 @@ fi echo-debug "Preliminary initialization completed." touch /var/run/cli +# Execute a custom startup script if present if [[ -x ${PROJECT_ROOT}/.docksal/services/cli/startup.sh ]]; then - echo-debug "Running Custom Startup Script..." + echo-debug "Running custom startup script..." + # TODO: should we source the script instead? ${PROJECT_ROOT}/.docksal/services/cli/startup.sh - echo-debug "Custom Startup Script Complete..." + if [[ $? == 0 ]]; then + echo-debug "Custom startup script executed successfully." + else + echo-debug "ERROR: Custom startup script execution failed." + fi fi # Execute passed CMD arguments diff --git a/tests/test.bats b/tests/test.bats index 82368b12..cde15598 100755 --- a/tests/test.bats +++ b/tests/test.bats @@ -265,16 +265,18 @@ _healthcheck_wait () rm -f .docksal/docksal-local.env } -@test "Check Custom Startup Script Works" { +@test "Check custom startup script" { [[ $SKIP == 1 ]] && skip - cd ../tests - echo "CLI_IMAGE=\"${IMAGE}\"" > .docksal/docksal-local.env - fin reset -f + make start + _healthcheck_wait - run fin exec -T 'cat /tmp/test-startup.txt' - [[ ${status} == 0 ]] && + run docker exec -u docker "${NAME}" cat /tmp/test-startup.txt + [[ ${status} == 0 ]] [[ "${output}" =~ "I ran properly" ]] + + ### Cleanup ### + make clean } @test "Check Platform.sh integration" { From c5dd4e5adabc30d7a8f6946af74d726fde96fe3a Mon Sep 17 00:00:00 2001 From: Leonid Makarov Date: Wed, 11 Jul 2018 01:55:17 -0700 Subject: [PATCH 34/45] Drop .docksalrc and refactor tests - Always use login sessions (bash -lc / bash -ilc) in tests to have variables loaded from ~/.profile and /etc/profile - Simplified command mode command in startup.sh - Removed global SKIP=1 in tests to make sure it's not committed accidentally - Updated tests to use Makefile commands where possible --- 5.6/Dockerfile | 1 - 5.6/config/.docksalrc | 9 ----- 5.6/startup.sh | 8 +--- 7.0/Dockerfile | 1 - 7.0/config/.docksalrc | 9 ----- 7.0/startup.sh | 8 +--- 7.1/Dockerfile | 1 - 7.1/config/.docksalrc | 9 ----- 7.1/startup.sh | 8 +--- 7.2/Dockerfile | 1 - 7.2/config/.docksalrc | 9 ----- 7.2/startup.sh | 8 +--- tests/test.bats | 90 +++++++++++++++++++++---------------------- 13 files changed, 51 insertions(+), 111 deletions(-) delete mode 100644 5.6/config/.docksalrc delete mode 100644 7.0/config/.docksalrc delete mode 100644 7.1/config/.docksalrc delete mode 100644 7.2/config/.docksalrc diff --git a/5.6/Dockerfile b/5.6/Dockerfile index cc476150..394d83f7 100644 --- a/5.6/Dockerfile +++ b/5.6/Dockerfile @@ -314,7 +314,6 @@ USER root COPY --from=mhbuild /go/bin/mhsendmail /usr/local/bin/mhsendmail # Copy configs and scripts COPY --chown=docker:docker config/.acquia $HOME/.acquia -COPY --chown=docker:docker config/.docksalrc $HOME/.docksalrc COPY --chown=docker:docker config/.drush $HOME/.drush COPY --chown=docker:docker config/.ssh $HOME/.ssh COPY config/supervisord.conf /etc/supervisor/conf.d/supervisord.conf diff --git a/5.6/config/.docksalrc b/5.6/config/.docksalrc deleted file mode 100644 index 40f7428b..00000000 --- a/5.6/config/.docksalrc +++ /dev/null @@ -1,9 +0,0 @@ -# Commands in this file will be sourced for both interactive and non-interactive sessions. - -# Allow alias expansion in non-interactive shells. -shopt -s expand_aliases - -# Source alias definitions. -if [ -f ~/.bash_aliases ]; then - . ~/.bash_aliases -fi diff --git a/5.6/startup.sh b/5.6/startup.sh index b066f5ad..7a615cae 100755 --- a/5.6/startup.sh +++ b/5.6/startup.sh @@ -131,15 +131,11 @@ if [[ -x ${PROJECT_ROOT}/.docksal/services/cli/startup.sh ]]; then fi # Execute passed CMD arguments -echo-debug "Executing the requested command..." +echo-debug "Passing execution to: $*" # Service mode (run as root) if [[ "$1" == "supervisord" ]]; then exec gosu root supervisord -c /etc/supervisor/supervisord.conf # Command mode (run as docker user) else - # This makes sure the environment is set up correctly for the docker user - DOCKSALRC='source $HOME/.docksalrc >/dev/null 2>&1' - # Launch the passed command in an non-interactive bash session under docker user - # $@ does not work here. $* has to be used. - exec gosu docker bash -c "$DOCKSALRC; exec $*" + exec gosu docker "$@" fi diff --git a/7.0/Dockerfile b/7.0/Dockerfile index 3c4acd41..6c121d6b 100644 --- a/7.0/Dockerfile +++ b/7.0/Dockerfile @@ -322,7 +322,6 @@ USER root COPY --from=mhbuild /go/bin/mhsendmail /usr/local/bin/mhsendmail # Copy configs and scripts COPY --chown=docker:docker config/.acquia $HOME/.acquia -COPY --chown=docker:docker config/.docksalrc $HOME/.docksalrc COPY --chown=docker:docker config/.drush $HOME/.drush COPY --chown=docker:docker config/.ssh $HOME/.ssh COPY config/supervisord.conf /etc/supervisor/conf.d/supervisord.conf diff --git a/7.0/config/.docksalrc b/7.0/config/.docksalrc deleted file mode 100644 index 40f7428b..00000000 --- a/7.0/config/.docksalrc +++ /dev/null @@ -1,9 +0,0 @@ -# Commands in this file will be sourced for both interactive and non-interactive sessions. - -# Allow alias expansion in non-interactive shells. -shopt -s expand_aliases - -# Source alias definitions. -if [ -f ~/.bash_aliases ]; then - . ~/.bash_aliases -fi diff --git a/7.0/startup.sh b/7.0/startup.sh index b066f5ad..7a615cae 100755 --- a/7.0/startup.sh +++ b/7.0/startup.sh @@ -131,15 +131,11 @@ if [[ -x ${PROJECT_ROOT}/.docksal/services/cli/startup.sh ]]; then fi # Execute passed CMD arguments -echo-debug "Executing the requested command..." +echo-debug "Passing execution to: $*" # Service mode (run as root) if [[ "$1" == "supervisord" ]]; then exec gosu root supervisord -c /etc/supervisor/supervisord.conf # Command mode (run as docker user) else - # This makes sure the environment is set up correctly for the docker user - DOCKSALRC='source $HOME/.docksalrc >/dev/null 2>&1' - # Launch the passed command in an non-interactive bash session under docker user - # $@ does not work here. $* has to be used. - exec gosu docker bash -c "$DOCKSALRC; exec $*" + exec gosu docker "$@" fi diff --git a/7.1/Dockerfile b/7.1/Dockerfile index d078303d..7057fc2c 100644 --- a/7.1/Dockerfile +++ b/7.1/Dockerfile @@ -322,7 +322,6 @@ USER root COPY --from=mhbuild /go/bin/mhsendmail /usr/local/bin/mhsendmail # Copy configs and scripts COPY --chown=docker:docker config/.acquia $HOME/.acquia -COPY --chown=docker:docker config/.docksalrc $HOME/.docksalrc COPY --chown=docker:docker config/.drush $HOME/.drush COPY --chown=docker:docker config/.ssh $HOME/.ssh COPY config/supervisord.conf /etc/supervisor/conf.d/supervisord.conf diff --git a/7.1/config/.docksalrc b/7.1/config/.docksalrc deleted file mode 100644 index 40f7428b..00000000 --- a/7.1/config/.docksalrc +++ /dev/null @@ -1,9 +0,0 @@ -# Commands in this file will be sourced for both interactive and non-interactive sessions. - -# Allow alias expansion in non-interactive shells. -shopt -s expand_aliases - -# Source alias definitions. -if [ -f ~/.bash_aliases ]; then - . ~/.bash_aliases -fi diff --git a/7.1/startup.sh b/7.1/startup.sh index b066f5ad..7a615cae 100755 --- a/7.1/startup.sh +++ b/7.1/startup.sh @@ -131,15 +131,11 @@ if [[ -x ${PROJECT_ROOT}/.docksal/services/cli/startup.sh ]]; then fi # Execute passed CMD arguments -echo-debug "Executing the requested command..." +echo-debug "Passing execution to: $*" # Service mode (run as root) if [[ "$1" == "supervisord" ]]; then exec gosu root supervisord -c /etc/supervisor/supervisord.conf # Command mode (run as docker user) else - # This makes sure the environment is set up correctly for the docker user - DOCKSALRC='source $HOME/.docksalrc >/dev/null 2>&1' - # Launch the passed command in an non-interactive bash session under docker user - # $@ does not work here. $* has to be used. - exec gosu docker bash -c "$DOCKSALRC; exec $*" + exec gosu docker "$@" fi diff --git a/7.2/Dockerfile b/7.2/Dockerfile index 27df80b4..0d0ab45a 100644 --- a/7.2/Dockerfile +++ b/7.2/Dockerfile @@ -324,7 +324,6 @@ USER root COPY --from=mhbuild /go/bin/mhsendmail /usr/local/bin/mhsendmail # Copy configs and scripts COPY --chown=docker:docker config/.acquia $HOME/.acquia -COPY --chown=docker:docker config/.docksalrc $HOME/.docksalrc COPY --chown=docker:docker config/.drush $HOME/.drush COPY --chown=docker:docker config/.ssh $HOME/.ssh COPY config/supervisord.conf /etc/supervisor/conf.d/supervisord.conf diff --git a/7.2/config/.docksalrc b/7.2/config/.docksalrc deleted file mode 100644 index 40f7428b..00000000 --- a/7.2/config/.docksalrc +++ /dev/null @@ -1,9 +0,0 @@ -# Commands in this file will be sourced for both interactive and non-interactive sessions. - -# Allow alias expansion in non-interactive shells. -shopt -s expand_aliases - -# Source alias definitions. -if [ -f ~/.bash_aliases ]; then - . ~/.bash_aliases -fi diff --git a/7.2/startup.sh b/7.2/startup.sh index b066f5ad..7a615cae 100755 --- a/7.2/startup.sh +++ b/7.2/startup.sh @@ -131,15 +131,11 @@ if [[ -x ${PROJECT_ROOT}/.docksal/services/cli/startup.sh ]]; then fi # Execute passed CMD arguments -echo-debug "Executing the requested command..." +echo-debug "Passing execution to: $*" # Service mode (run as root) if [[ "$1" == "supervisord" ]]; then exec gosu root supervisord -c /etc/supervisor/supervisord.conf # Command mode (run as docker user) else - # This makes sure the environment is set up correctly for the docker user - DOCKSALRC='source $HOME/.docksalrc >/dev/null 2>&1' - # Launch the passed command in an non-interactive bash session under docker user - # $@ does not work here. $* has to be used. - exec gosu docker bash -c "$DOCKSALRC; exec $*" + exec gosu docker "$@" fi diff --git a/tests/test.bats b/tests/test.bats index cde15598..193e0cbb 100755 --- a/tests/test.bats +++ b/tests/test.bats @@ -62,10 +62,8 @@ _healthcheck_wait () return 0 } - -# Global skip -# Uncomment below, then comment skip in the test you want to debug. When done, reverse. -#SKIP=1 +# To work on a specific test: +# run `export SKIP=1` locally, then comment skip in the test you want to debug @test "Bare service" { [[ $SKIP == 1 ]] && skip @@ -113,7 +111,7 @@ _healthcheck_wait () unset output # Check PHP modules - run bash -c "docker exec '${NAME}' php -m | diff php-modules.txt -" + run bash -lc "docker exec -u docker '${NAME}' php -m | diff php-modules.txt -" [[ ${status} == 0 ]] unset output @@ -121,88 +119,80 @@ _healthcheck_wait () docker rm -vf "$NAME" >/dev/null 2>&1 || true } +# Examples of using Makefile commands +# make start, make exec, make clean @test "Configuration overrides" { [[ $SKIP == 1 ]] && skip ### Setup ### - docker rm -vf "$NAME" >/dev/null 2>&1 || true - docker run --name "$NAME" -d \ - -v /home/docker \ - -v $(pwd)/../tests:/var/www \ - -e XDEBUG_ENABLED=1 \ - "$IMAGE" + make start -e ENV='-e XDEBUG_ENABLED=1' _healthcheck_wait ### Tests ### # Check PHP FPM settings overrides - run docker exec -u docker "$NAME" /var/www/scripts/test-php-fpm.sh index.php + run make exec -e CMD='/var/www/scripts/test-php-fpm.sh index.php' echo "$output" | grep "memory_limit" | grep "512M" unset output # Check xdebug was enabled - run docker exec -u docker "$NAME" php -m + run make exec -e CMD='php -m' echo "$output" | grep -e "^xdebug$" unset output # Check PHP CLI overrides - run docker exec -u docker "$NAME" php -i + run make exec -e CMD='php -i' echo "$output" | grep "memory_limit => 128M => 128M" unset output ### Cleanup ### - docker rm -vf "$NAME" >/dev/null 2>&1 || true + make clean } @test "Check binaries and versions" { [[ $SKIP == 1 ]] && skip ### Setup ### - docker rm -vf "$NAME" >/dev/null 2>&1 || true - docker run --name "$NAME" -d \ - -v /home/docker \ - -v $(pwd)/../tests:/var/www \ - -e XDEBUG_ENABLED=1 \ - "$IMAGE" + make start _healthcheck_wait ### Tests ### # Check Composer version - run docker exec -u docker "$NAME" bash -c 'composer --version | grep "^Composer version ${COMPOSER_VERSION} "' + run docker exec -u docker "$NAME" bash -lc 'composer --version | grep "^Composer version ${COMPOSER_VERSION} "' [[ ${status} == 0 ]] unset output # Check Drush Launcher version - run docker exec -u docker "$NAME" bash -c 'drush --version | grep "^Drush Launcher Version: ${DRUSH_LAUNCHER_VERSION}$"' + run docker exec -u docker "$NAME" bash -lc 'drush --version | grep "^Drush Launcher Version: ${DRUSH_LAUNCHER_VERSION}$"' [[ ${status} == 0 ]] unset output # Check Drush version - run docker exec -u docker "$NAME" bash -c 'drush --version | grep "^ Drush Version : ${DRUSH_VERSION} $"' + run docker exec -u docker "$NAME" bash -lc 'drush --version | grep "^ Drush Version : ${DRUSH_VERSION} $"' [[ ${status} == 0 ]] unset output # Check Drupal Console version - run docker exec -u docker "$NAME" bash -c 'drupal --version | grep "^Drupal Console Launcher ${DRUPAL_CONSOLE_LAUNCHER_VERSION}$"' + run docker exec -u docker "$NAME" bash -lc 'drupal --version | grep "^Drupal Console Launcher ${DRUPAL_CONSOLE_LAUNCHER_VERSION}$"' [[ ${status} == 0 ]] unset output # Check Wordpress CLI version - run docker exec -u docker "$NAME" bash -c 'wp --version | grep "^WP-CLI ${WPCLI_VERSION}$"' + run docker exec -u docker "$NAME" bash -lc 'wp --version | grep "^WP-CLI ${WPCLI_VERSION}$"' [[ ${status} == 0 ]] unset output # Check Magento 2 Code Generator version # TODO: this needs to be replaced with the actual version check # See https://github.com/staempfli/magento2-code-generator/issues/15 - #run docker exec -u docker "$NAME" bash -c 'mg2-codegen --version | grep "^mg2-codegen ${MG_CODEGEN_VERSION}$"' - run docker exec -u docker "$NAME" bash -c 'mg2-codegen --version | grep "^mg2-codegen @git-version@$"' + #run docker exec -u docker "$NAME" bash -lc 'mg2-codegen --version | grep "^mg2-codegen ${MG_CODEGEN_VERSION}$"' + run docker exec -u docker "$NAME" bash -lc 'mg2-codegen --version | grep "^mg2-codegen @git-version@$"' [[ ${status} == 0 ]] unset output # Check Blackfire CLI version - run docker exec -u docker "$NAME" bash -c 'blackfire version | grep "^blackfire ${BLACKFIRE_VERSION} "' + run docker exec -u docker "$NAME" bash -lc 'blackfire version | grep "^blackfire ${BLACKFIRE_VERSION} "' [[ ${status} == 0 ]] unset output @@ -212,57 +202,63 @@ _healthcheck_wait () unset output # Check Terminus version - run docker exec -u docker "$NAME" bash -c 'terminus --version | grep "^Terminus ${TERMINUS_VERSION}$"' + run docker exec -u docker "$NAME" bash -lc 'terminus --version | grep "^Terminus ${TERMINUS_VERSION}$"' [[ ${status} == 0 ]] unset output # Check Platform CLI version - run docker exec -u docker "$NAME" bash -c 'platform --version | grep "Platform.sh CLI ${PLATFORMSH_CLI_VERSION}"' + run docker exec -u docker "$NAME" bash -lc 'platform --version | grep "Platform.sh CLI ${PLATFORMSH_CLI_VERSION}"' [[ ${status} == 0 ]] unset output ### Cleanup ### - docker rm -vf "$NAME" >/dev/null 2>&1 || true + make clean } @test "Check config templates" { [[ $SKIP == 1 ]] && skip - ### Setup ### - cd ../tests - echo "CLI_IMAGE=\"${IMAGE}\"" > .docksal/docksal-local.env - fin reset -f - - ### Tests ### + # Source and allexport (set -a) variables from docksal.env + set -a; source $(pwd)/../tests/.docksal/docksal.env; set +a - # Load environment variables from docksal.env and confirm then are not empty - source .docksal/docksal.env + # Config variables were loaded [[ "${SECRET_ACAPI_EMAIL}" != "" ]] [[ "${SECRET_ACAPI_KEY}" != "" ]] [[ "${SECRET_SSH_PRIVATE_KEY}" != "" ]] + ### Setup ### + make start -e ENV="\ + -e SECRET_ACAPI_EMAIL \ + -e SECRET_ACAPI_KEY \ + -e SECRET_SSH_PRIVATE_KEY \ + " + _healthcheck_wait + + ### Tests ### + # Check Acquia Cloud API conf - run fin exec 'echo ${SECRET_ACAPI_EMAIL}' + run make exec -e CMD='echo ${SECRET_ACAPI_EMAIL}' [[ "${output}" != "" ]] unset output - run fin exec 'echo ${SECRET_ACAPI_KEY}' + run make exec -e CMD='echo ${SECRET_ACAPI_KEY}' [[ "${output}" != "" ]] unset output - run fin exec 'grep "${SECRET_ACAPI_EMAIL}" "$HOME/.acquia/cloudapi.conf" && grep "${SECRET_ACAPI_KEY}" "$HOME/.acquia/cloudapi.conf"' + # TODO: figure out how to properly use 'make exec' here (escape quotes) + run docker exec -u docker "${NAME}" bash -lc 'grep "${SECRET_ACAPI_EMAIL}" ${HOME}/.acquia/cloudapi.conf && grep "${SECRET_ACAPI_KEY}" ${HOME}/.acquia/cloudapi.conf' [[ ${status} == 0 ]] unset output # Check private SSH key - run fin exec 'echo ${SECRET_SSH_PRIVATE_KEY}' + run make exec -e CMD='echo ${SECRET_SSH_PRIVATE_KEY}' [[ "${output}" != "" ]] unset output - run fin exec 'echo "${SECRET_SSH_PRIVATE_KEY}" | diff $HOME/.ssh/id_rsa -' + # TODO: figure out how to properly use 'make exec' here (escape quotes) + run docker exec -u docker "${NAME}" bash -lc 'echo "${SECRET_SSH_PRIVATE_KEY}" | diff ${HOME}/.ssh/id_rsa -' [[ ${status} == 0 ]] unset output ### Cleanup ### - fin rm -f - rm -f .docksal/docksal-local.env + make clean } @test "Check custom startup script" { From 76c248dcc23d3e0cb4b8f31549ee1c2bc449cfab Mon Sep 17 00:00:00 2001 From: Leonid Makarov Date: Thu, 12 Jul 2018 19:24:03 -0700 Subject: [PATCH 35/45] Run make shell as an interactive login session --- 5.6/Makefile | 2 +- 7.0/Makefile | 2 +- 7.1/Makefile | 2 +- 7.2/Makefile | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/5.6/Makefile b/5.6/Makefile index 4f63dac3..57347a60 100644 --- a/5.6/Makefile +++ b/5.6/Makefile @@ -36,7 +36,7 @@ exec-it: @docker exec -u docker -it $(NAME) bash -ilc "$(CMD)" shell: - @docker exec -u docker -it $(NAME) bash + @docker exec -u docker -it $(NAME) bash -il stop: docker stop $(NAME) diff --git a/7.0/Makefile b/7.0/Makefile index e9d5b1b9..792cebd2 100644 --- a/7.0/Makefile +++ b/7.0/Makefile @@ -36,7 +36,7 @@ exec-it: @docker exec -u docker -it $(NAME) bash -ilc "$(CMD)" shell: - @docker exec -u docker -it $(NAME) bash + @docker exec -u docker -it $(NAME) bash -il stop: docker stop $(NAME) diff --git a/7.1/Makefile b/7.1/Makefile index d7738dc1..7441f0fe 100644 --- a/7.1/Makefile +++ b/7.1/Makefile @@ -36,7 +36,7 @@ exec-it: @docker exec -u docker -it $(NAME) bash -ilc "$(CMD)" shell: - @docker exec -u docker -it $(NAME) bash + @docker exec -u docker -it $(NAME) bash -il stop: docker stop $(NAME) diff --git a/7.2/Makefile b/7.2/Makefile index db924e9f..a138979b 100644 --- a/7.2/Makefile +++ b/7.2/Makefile @@ -36,7 +36,7 @@ exec-it: @docker exec -u docker -it $(NAME) bash -ilc "$(CMD)" shell: - @docker exec -u docker -it $(NAME) bash + @docker exec -u docker -it $(NAME) bash -il stop: docker stop $(NAME) From 62d6c25d24792560b67232708f8f6ebb05d414fd Mon Sep 17 00:00:00 2001 From: Leonid Makarov Date: Thu, 12 Jul 2018 19:29:46 -0700 Subject: [PATCH 36/45] Have supervisor split logs for services With the previous setup logs were streamed twice to stdout/stderr (debug logging + stdour_logfile/stderr_logfile settings) Now, logs will go into stdout/stderr for supervisor (debug logging) and also into separate log files per service (stdout_logfile/stderr_logfile). The amount of data written to disk stays the same, it's just more organized now. Note: without debug logging level for supervisor it would be difficult to tell apart which service spits the logs. --- 5.6/config/supervisord.conf | 17 +++++++++-------- 7.0/config/supervisord.conf | 17 +++++++++-------- 7.1/config/supervisord.conf | 17 +++++++++-------- 7.2/config/supervisord.conf | 17 +++++++++-------- 4 files changed, 36 insertions(+), 32 deletions(-) diff --git a/5.6/config/supervisord.conf b/5.6/config/supervisord.conf index 4326e8c7..d7306e21 100644 --- a/5.6/config/supervisord.conf +++ b/5.6/config/supervisord.conf @@ -1,21 +1,22 @@ [supervisord] nodaemon = true +# debug prints output from all services to stdout/stderr. +# This way logs can be reviewed with docker logs. +# Additionalluy, logs from specific services are forwarded to individual files on disk. loglevel = debug [program:php-fpm] command = /usr/local/sbin/php-fpm -stdout_logfile = /dev/stdout -stdout_logfile_maxbytes = 0 -stderr_logfile = /dev/stderr -stderr_logfile_maxbytes = 0 +stdout_logfile = /var/log/supervisor/php-fpm-stdout +stderr_logfile = /var/log/supervisor/php-fpm-stderr [program:sshd] command = /usr/sbin/sshd -D -stdout_logfile = /dev/stdout -stdout_logfile_maxbytes = 0 -stderr_logfile = /dev/stderr -stderr_logfile_maxbytes = 0 +stdout_logfile = /var/log/supervisor/sshd-stdout +stderr_logfile = /var/log/supervisor/sshd-stderr [program:cron] # Cron will only log to syslog and nothing else... command = /usr/sbin/cron -f +stdout_logfile = /var/log/supervisor/cron-stdout +stderr_logfile = /var/log/supervisor/cron-stderr diff --git a/7.0/config/supervisord.conf b/7.0/config/supervisord.conf index 4326e8c7..d7306e21 100644 --- a/7.0/config/supervisord.conf +++ b/7.0/config/supervisord.conf @@ -1,21 +1,22 @@ [supervisord] nodaemon = true +# debug prints output from all services to stdout/stderr. +# This way logs can be reviewed with docker logs. +# Additionalluy, logs from specific services are forwarded to individual files on disk. loglevel = debug [program:php-fpm] command = /usr/local/sbin/php-fpm -stdout_logfile = /dev/stdout -stdout_logfile_maxbytes = 0 -stderr_logfile = /dev/stderr -stderr_logfile_maxbytes = 0 +stdout_logfile = /var/log/supervisor/php-fpm-stdout +stderr_logfile = /var/log/supervisor/php-fpm-stderr [program:sshd] command = /usr/sbin/sshd -D -stdout_logfile = /dev/stdout -stdout_logfile_maxbytes = 0 -stderr_logfile = /dev/stderr -stderr_logfile_maxbytes = 0 +stdout_logfile = /var/log/supervisor/sshd-stdout +stderr_logfile = /var/log/supervisor/sshd-stderr [program:cron] # Cron will only log to syslog and nothing else... command = /usr/sbin/cron -f +stdout_logfile = /var/log/supervisor/cron-stdout +stderr_logfile = /var/log/supervisor/cron-stderr diff --git a/7.1/config/supervisord.conf b/7.1/config/supervisord.conf index 4326e8c7..d7306e21 100644 --- a/7.1/config/supervisord.conf +++ b/7.1/config/supervisord.conf @@ -1,21 +1,22 @@ [supervisord] nodaemon = true +# debug prints output from all services to stdout/stderr. +# This way logs can be reviewed with docker logs. +# Additionalluy, logs from specific services are forwarded to individual files on disk. loglevel = debug [program:php-fpm] command = /usr/local/sbin/php-fpm -stdout_logfile = /dev/stdout -stdout_logfile_maxbytes = 0 -stderr_logfile = /dev/stderr -stderr_logfile_maxbytes = 0 +stdout_logfile = /var/log/supervisor/php-fpm-stdout +stderr_logfile = /var/log/supervisor/php-fpm-stderr [program:sshd] command = /usr/sbin/sshd -D -stdout_logfile = /dev/stdout -stdout_logfile_maxbytes = 0 -stderr_logfile = /dev/stderr -stderr_logfile_maxbytes = 0 +stdout_logfile = /var/log/supervisor/sshd-stdout +stderr_logfile = /var/log/supervisor/sshd-stderr [program:cron] # Cron will only log to syslog and nothing else... command = /usr/sbin/cron -f +stdout_logfile = /var/log/supervisor/cron-stdout +stderr_logfile = /var/log/supervisor/cron-stderr diff --git a/7.2/config/supervisord.conf b/7.2/config/supervisord.conf index 4326e8c7..d7306e21 100644 --- a/7.2/config/supervisord.conf +++ b/7.2/config/supervisord.conf @@ -1,21 +1,22 @@ [supervisord] nodaemon = true +# debug prints output from all services to stdout/stderr. +# This way logs can be reviewed with docker logs. +# Additionalluy, logs from specific services are forwarded to individual files on disk. loglevel = debug [program:php-fpm] command = /usr/local/sbin/php-fpm -stdout_logfile = /dev/stdout -stdout_logfile_maxbytes = 0 -stderr_logfile = /dev/stderr -stderr_logfile_maxbytes = 0 +stdout_logfile = /var/log/supervisor/php-fpm-stdout +stderr_logfile = /var/log/supervisor/php-fpm-stderr [program:sshd] command = /usr/sbin/sshd -D -stdout_logfile = /dev/stdout -stdout_logfile_maxbytes = 0 -stderr_logfile = /dev/stderr -stderr_logfile_maxbytes = 0 +stdout_logfile = /var/log/supervisor/sshd-stdout +stderr_logfile = /var/log/supervisor/sshd-stderr [program:cron] # Cron will only log to syslog and nothing else... command = /usr/sbin/cron -f +stdout_logfile = /var/log/supervisor/cron-stdout +stderr_logfile = /var/log/supervisor/cron-stderr From 82a82581ddc2c667a45f2a76b1fe130e2636de56 Mon Sep 17 00:00:00 2001 From: Leonid Makarov Date: Fri, 13 Jul 2018 11:45:18 -0700 Subject: [PATCH 37/45] Added nvm back. Closes #51 - Back to installing node via nvm - Yarn is not installed via the official install script, which supports versions - Versions: nvm v0.33.11, default nodejs v8.11.3, yarn v1.8.0 --- 5.6/Dockerfile | 33 ++++++++++++++++----------------- 7.0/Dockerfile | 33 ++++++++++++++++----------------- 7.1/Dockerfile | 33 ++++++++++++++++----------------- 7.2/Dockerfile | 33 ++++++++++++++++----------------- 4 files changed, 64 insertions(+), 68 deletions(-) diff --git a/5.6/Dockerfile b/5.6/Dockerfile index 394d83f7..0a0f9da0 100644 --- a/5.6/Dockerfile +++ b/5.6/Dockerfile @@ -246,23 +246,6 @@ RUN set -xe; \ # Make all downloaded binaries executable in one shot (cd /usr/local/bin && chmod +x composer drush8 drush drupal wp blackfire platform); -# Node.js -ENV NODE_VERSION=8.x -RUN set -xe; \ - # Node.js repo - curl -fsSL https://deb.nodesource.com/gpgkey/nodesource.gpg.key | apt-key add -; \ - echo "deb https://deb.nodesource.com/node_${NODE_VERSION} jessie main" | sudo tee /etc/apt/sources.list.d/nodesource.list; \ - echo "deb-src https://deb.nodesource.com/node_${NODE_VERSION} jessie main" | sudo tee -a /etc/apt/sources.list.d/nodesource.list; \ - # yarn repo - curl -fsSL https://dl.yarnpkg.com/debian/pubkey.gpg | apt-key add -; \ - echo "deb https://dl.yarnpkg.com/debian/ stable main" | tee /etc/apt/sources.list.d/yarn.list; \ - apt-get update >/dev/null; \ - apt-get -y --no-install-recommends install >/dev/null \ - nodejs \ - yarn \ - ;\ - apt-get clean; rm -rf /var/lib/apt/lists/*; - # Ruby RUN set -xe; \ apt-get update >/dev/null; \ @@ -308,6 +291,22 @@ RUN set -xe; \ drush dl registry_rebuild --default-major=7 --destination=$HOME/.drush >/dev/null; \ drush cc drush +# Node.js (installed as user) +ENV \ + NVM_VERSION=0.33.11 \ + NODE_VERSION=8.11.3 \ + YARN_VERSION=1.8.0 +# Don't use -x here, as nvm prints too much stuff +RUN set -e; \ + # NVM and a defaut Node.js version + export PROFILE="$HOME/.profile"; \ + curl -fsSL https://raw.githubusercontent.com/creationix/nvm/v${NVM_VERSION}/install.sh | bash >/dev/null; \ + # Reload profile to load nvm (needed by Yarn installation below) + . $HOME/.profile; \ + # Yarn + export YARN_PROFILE="$HOME/.profile"; \ + curl -fsSL https://yarnpkg.com/install.sh | bash -s -- --version ${YARN_VERSION} >/dev/null + USER root # Copy mhsendmail binary from stage 1 diff --git a/7.0/Dockerfile b/7.0/Dockerfile index 6c121d6b..7280bd0b 100644 --- a/7.0/Dockerfile +++ b/7.0/Dockerfile @@ -254,23 +254,6 @@ RUN set -xe; \ # Make all downloaded binaries executable in one shot (cd /usr/local/bin && chmod +x composer drush8 drush drupal wp blackfire platform); -# Node.js -ENV NODE_VERSION=8.x -RUN set -xe; \ - # Node.js repo - curl -fsSL https://deb.nodesource.com/gpgkey/nodesource.gpg.key | apt-key add -; \ - echo "deb https://deb.nodesource.com/node_${NODE_VERSION} jessie main" | sudo tee /etc/apt/sources.list.d/nodesource.list; \ - echo "deb-src https://deb.nodesource.com/node_${NODE_VERSION} jessie main" | sudo tee -a /etc/apt/sources.list.d/nodesource.list; \ - # yarn repo - curl -fsSL https://dl.yarnpkg.com/debian/pubkey.gpg | apt-key add -; \ - echo "deb https://dl.yarnpkg.com/debian/ stable main" | tee /etc/apt/sources.list.d/yarn.list; \ - apt-get update >/dev/null; \ - apt-get -y --no-install-recommends install >/dev/null \ - nodejs \ - yarn \ - ;\ - apt-get clean; rm -rf /var/lib/apt/lists/*; - # Ruby RUN set -xe; \ apt-get update >/dev/null; \ @@ -316,6 +299,22 @@ RUN set -xe; \ drush dl registry_rebuild --default-major=7 --destination=$HOME/.drush >/dev/null; \ drush cc drush +# Node.js (installed as user) +ENV \ + NVM_VERSION=0.33.11 \ + NODE_VERSION=8.11.3 \ + YARN_VERSION=1.8.0 +# Don't use -x here, as nvm prints too much stuff +RUN set -e; \ + # NVM and a defaut Node.js version + export PROFILE="$HOME/.profile"; \ + curl -fsSL https://raw.githubusercontent.com/creationix/nvm/v${NVM_VERSION}/install.sh | bash >/dev/null; \ + # Reload profile to load nvm (needed by Yarn installation below) + . $HOME/.profile; \ + # Yarn + export YARN_PROFILE="$HOME/.profile"; \ + curl -fsSL https://yarnpkg.com/install.sh | bash -s -- --version ${YARN_VERSION} >/dev/null + USER root # Copy mhsendmail binary from stage 1 diff --git a/7.1/Dockerfile b/7.1/Dockerfile index 7057fc2c..2d466f8b 100644 --- a/7.1/Dockerfile +++ b/7.1/Dockerfile @@ -254,23 +254,6 @@ RUN set -xe; \ # Make all downloaded binaries executable in one shot (cd /usr/local/bin && chmod +x composer drush8 drush drupal wp blackfire platform); -# Node.js -ENV NODE_VERSION=8.x -RUN set -xe; \ - # Node.js repo - curl -fsSL https://deb.nodesource.com/gpgkey/nodesource.gpg.key | apt-key add -; \ - echo "deb https://deb.nodesource.com/node_${NODE_VERSION} jessie main" | sudo tee /etc/apt/sources.list.d/nodesource.list; \ - echo "deb-src https://deb.nodesource.com/node_${NODE_VERSION} jessie main" | sudo tee -a /etc/apt/sources.list.d/nodesource.list; \ - # yarn repo - curl -fsSL https://dl.yarnpkg.com/debian/pubkey.gpg | apt-key add -; \ - echo "deb https://dl.yarnpkg.com/debian/ stable main" | tee /etc/apt/sources.list.d/yarn.list; \ - apt-get update >/dev/null; \ - apt-get -y --no-install-recommends install >/dev/null \ - nodejs \ - yarn \ - ;\ - apt-get clean; rm -rf /var/lib/apt/lists/*; - # Ruby RUN set -xe; \ apt-get update >/dev/null; \ @@ -316,6 +299,22 @@ RUN set -xe; \ drush dl registry_rebuild --default-major=7 --destination=$HOME/.drush >/dev/null; \ drush cc drush +# Node.js (installed as user) +ENV \ + NVM_VERSION=0.33.11 \ + NODE_VERSION=8.11.3 \ + YARN_VERSION=1.8.0 +# Don't use -x here, as nvm prints too much stuff +RUN set -e; \ + # NVM and a defaut Node.js version + export PROFILE="$HOME/.profile"; \ + curl -fsSL https://raw.githubusercontent.com/creationix/nvm/v${NVM_VERSION}/install.sh | bash >/dev/null; \ + # Reload profile to load nvm (needed by Yarn installation below) + . $HOME/.profile; \ + # Yarn + export YARN_PROFILE="$HOME/.profile"; \ + curl -fsSL https://yarnpkg.com/install.sh | bash -s -- --version ${YARN_VERSION} >/dev/null + USER root # Copy mhsendmail binary from stage 1 diff --git a/7.2/Dockerfile b/7.2/Dockerfile index 0d0ab45a..063afd8d 100644 --- a/7.2/Dockerfile +++ b/7.2/Dockerfile @@ -256,23 +256,6 @@ RUN set -xe; \ # Make all downloaded binaries executable in one shot (cd /usr/local/bin && chmod +x composer drush8 drush drupal wp blackfire platform); -# Node.js -ENV NODE_VERSION=8.x -RUN set -xe; \ - # Node.js repo - curl -fsSL https://deb.nodesource.com/gpgkey/nodesource.gpg.key | apt-key add -; \ - echo "deb https://deb.nodesource.com/node_${NODE_VERSION} jessie main" | sudo tee /etc/apt/sources.list.d/nodesource.list; \ - echo "deb-src https://deb.nodesource.com/node_${NODE_VERSION} jessie main" | sudo tee -a /etc/apt/sources.list.d/nodesource.list; \ - # yarn repo - curl -fsSL https://dl.yarnpkg.com/debian/pubkey.gpg | apt-key add -; \ - echo "deb https://dl.yarnpkg.com/debian/ stable main" | tee /etc/apt/sources.list.d/yarn.list; \ - apt-get update >/dev/null; \ - apt-get -y --no-install-recommends install >/dev/null \ - nodejs \ - yarn \ - ;\ - apt-get clean; rm -rf /var/lib/apt/lists/*; - # Ruby RUN set -xe; \ apt-get update >/dev/null; \ @@ -318,6 +301,22 @@ RUN set -xe; \ drush dl registry_rebuild --default-major=7 --destination=$HOME/.drush >/dev/null; \ drush cc drush +# Node.js (installed as user) +ENV \ + NVM_VERSION=0.33.11 \ + NODE_VERSION=8.11.3 \ + YARN_VERSION=1.8.0 +# Don't use -x here, as nvm prints too much stuff +RUN set -e; \ + # NVM and a defaut Node.js version + export PROFILE="$HOME/.profile"; \ + curl -fsSL https://raw.githubusercontent.com/creationix/nvm/v${NVM_VERSION}/install.sh | bash >/dev/null; \ + # Reload profile to load nvm (needed by Yarn installation below) + . $HOME/.profile; \ + # Yarn + export YARN_PROFILE="$HOME/.profile"; \ + curl -fsSL https://yarnpkg.com/install.sh | bash -s -- --version ${YARN_VERSION} >/dev/null + USER root # Copy mhsendmail binary from stage 1 From 1eb5d57e29e9898b3d6292e6ff2a46ab5a5611b4 Mon Sep 17 00:00:00 2001 From: Leonid Makarov Date: Fri, 13 Jul 2018 11:47:21 -0700 Subject: [PATCH 38/45] Cloud9: updated Makefile and tests to use make commands --- cloud9/Makefile | 24 +++++++++++++++++------- cloud9/tests/test.bats | 16 +++++----------- 2 files changed, 22 insertions(+), 18 deletions(-) diff --git a/cloud9/Makefile b/cloud9/Makefile index 2fe4c23c..d9c49e2f 100644 --- a/cloud9/Makefile +++ b/cloud9/Makefile @@ -1,3 +1,4 @@ +-include ../tests/env_make -include env_make VERSION ?= 7.1 @@ -5,6 +6,7 @@ REPO = docksal/cli FROM_TAG = build-$(VERSION) TAG = $(FROM_TAG)-ide NAME = docksal-cli-$(VERSION)-ide +CWD = $(shell pwd) # Improve write performance for /home/docker by turning it into a volume VOLUMES += -v /home/docker @@ -20,17 +22,22 @@ test: push: docker push $(REPO):$(TAG) -shell: - docker run --rm --name $(NAME) -it $(PORTS) $(VOLUMES) $(ENV) $(REPO):$(TAG) /bin/bash - -run: +run: clean docker run --rm --name $(NAME) -it $(PORTS) $(VOLUMES) $(ENV) $(REPO):$(TAG) -start: +start: clean docker run -d --name $(NAME) $(PORTS) $(VOLUMES) $(ENV) $(REPO):$(TAG) +# Non-interactive and non-tty docker exec (uses LF instead of CRLF line endings) exec: - docker exec -it $(NAME) /bin/bash + @docker exec -u docker $(NAME) bash -lc "$(CMD)" + +# Interactive docker exec +exec-it: + @docker exec -u docker -it $(NAME) bash -ilc "$(CMD)" + +shell: + @docker exec -u docker -it $(NAME) bash -il stop: docker stop $(NAME) @@ -38,8 +45,11 @@ stop: logs: docker logs $(NAME) +logs-follow: + docker logs -f $(NAME) + clean: - docker rm -f $(NAME) + docker rm -vf $(NAME) >/dev/null 2>&1 || true release: build make push -e TAG=$(TAG) diff --git a/cloud9/tests/test.bats b/cloud9/tests/test.bats index 2e00e2b2..cbd9bfbd 100755 --- a/cloud9/tests/test.bats +++ b/cloud9/tests/test.bats @@ -62,28 +62,22 @@ _healthcheck_wait () return 0 } - -# Global skip -# Uncomment below, then comment skip in the test you want to debug. When done, reverse. -#SKIP=1 +# To work on a specific test: +# run `export SKIP=1` locally, then comment skip in the test you want to debug @test "Cloud 9 IDE" { [[ $SKIP == 1 ]] && skip ### Setup ### - docker rm -vf "$NAME" >/dev/null 2>&1 || true - docker run --name "$NAME" -d \ - -v /home/docker \ - -v $(pwd)/../tests/docroot:/var/www/docroot \ - "$IMAGE" + make start _healthcheck_wait ### Tests ### - run docker logs "$NAME" + run make logs echo "$output" | grep "Cloud9 is up and running" unset output ### Cleanup ### - docker rm -vf "$NAME" >/dev/null 2>&1 || true + make clean } From 8a0fe74bc2cc7f7def5c576bd9633ac3b3fdfa12 Mon Sep 17 00:00:00 2001 From: Leonid Makarov Date: Fri, 13 Jul 2018 11:51:49 -0700 Subject: [PATCH 39/45] Cloud9: Added support for running C9 with nodejs installed via nvm Using "bash -lc" in the c9 supervisor task. This makes sure nvm is loaded and node available. --- cloud9/Dockerfile | 8 ++++++-- cloud9/config/supervisord-cloud9.conf | 3 ++- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/cloud9/Dockerfile b/cloud9/Dockerfile index 6278b989..955da3b8 100644 --- a/cloud9/Dockerfile +++ b/cloud9/Dockerfile @@ -8,9 +8,13 @@ ARG DEBIAN_FRONTEND=noninteractive # Run as docker, so we don't have to fix permissions USER docker -ENV C9SDK_PATH=/home/docker/c9sdk +ARG HOME=/home/docker +ENV C9SDK_PATH=$HOME/c9sdk # Cloud9 IDE and dependencies -RUN set -x; \ +RUN \ + # Always source user profile when provisioning as user (necessary for nvm/etc. to load) + . $HOME/.profile; \ + set -xe; \ buildDeps=" \ g++ \ make \ diff --git a/cloud9/config/supervisord-cloud9.conf b/cloud9/config/supervisord-cloud9.conf index 86d7f9d3..23cc08af 100644 --- a/cloud9/config/supervisord-cloud9.conf +++ b/cloud9/config/supervisord-cloud9.conf @@ -1,7 +1,8 @@ # Cloud9 IDE [program:c9] -command = gosu docker node /home/docker/c9sdk/server.js -l 0.0.0.0 -p 3000 -w /var/www -a : stdout_logfile = /dev/stdout stdout_logfile_maxbytes = 0 stderr_logfile = /dev/stderr stderr_logfile_maxbytes = 0 +# Using bash -lc here to load docker user profile (necessary for nvn/node to initialize) +command = gosu docker bash -lc 'node ${C9SDK_PATH}/server.js -l 0.0.0.0 -p 3000 -w /var/www -a :' From 4c060b254e1156c54f6a0f09b173470a8cad6064 Mon Sep 17 00:00:00 2001 From: Leonid Makarov Date: Fri, 13 Jul 2018 11:52:24 -0700 Subject: [PATCH 40/45] Cloud9: Updated log settings for the c9 supervisor task --- cloud9/config/supervisord-cloud9.conf | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/cloud9/config/supervisord-cloud9.conf b/cloud9/config/supervisord-cloud9.conf index 23cc08af..ae544992 100644 --- a/cloud9/config/supervisord-cloud9.conf +++ b/cloud9/config/supervisord-cloud9.conf @@ -1,8 +1,6 @@ # Cloud9 IDE [program:c9] -stdout_logfile = /dev/stdout -stdout_logfile_maxbytes = 0 -stderr_logfile = /dev/stderr -stderr_logfile_maxbytes = 0 # Using bash -lc here to load docker user profile (necessary for nvn/node to initialize) command = gosu docker bash -lc 'node ${C9SDK_PATH}/server.js -l 0.0.0.0 -p 3000 -w /var/www -a :' +stdout_logfile = /var/log/supervisor/c9-stdout +stderr_logfile = /var/log/supervisor/c9-stderr From 59eeea28b2a473800036ec86a6c5c968f2fe6575 Mon Sep 17 00:00:00 2001 From: Leonid Makarov Date: Fri, 13 Jul 2018 11:53:03 -0700 Subject: [PATCH 41/45] Cloud9: removed --force-yes from apt-get install It's deprecated --- cloud9/Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cloud9/Dockerfile b/cloud9/Dockerfile index 955da3b8..fb77561b 100644 --- a/cloud9/Dockerfile +++ b/cloud9/Dockerfile @@ -20,7 +20,7 @@ RUN \ make \ ";\ sudo apt-get update; \ - sudo apt-get -y --force-yes --no-install-recommends install >/dev/null \ + sudo apt-get -y --no-install-recommends install >/dev/null \ $buildDeps \ tmux \ ;\ From 2a99a9cac0b4f9aa65209fd37f5508ba4d55c0ff Mon Sep 17 00:00:00 2001 From: Leonid Makarov Date: Fri, 13 Jul 2018 11:57:43 -0700 Subject: [PATCH 42/45] Cloud9: updates to the installation process - added --depth=1 to git clone to save some space - muted stdout from install scripts - added explanation about the installation process mess --- cloud9/Dockerfile | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/cloud9/Dockerfile b/cloud9/Dockerfile index fb77561b..11bb7741 100644 --- a/cloud9/Dockerfile +++ b/cloud9/Dockerfile @@ -25,11 +25,19 @@ RUN \ tmux \ ;\ \ - git clone https://github.com/c9/core.git ${C9SDK_PATH}; \ + # Cloud9 installation is a mess. + # Using the installer script on its own results in "unable to install pty.js module" at runtime. + # This can be addressed by using the link.sh script, however + # link.sh fails if c9/core is installed in ~/.c9. It complains but then works fine if another directory is used (e.g. ~/c9sdk) + # So we end up with c9 stuff installed in two places (~/.c9 and ~/c9sdk), but at least it works this way. + # TODO: revise c9 installation + git clone --depth=1 https://github.com/c9/core.git ${C9SDK_PATH} >/dev/null; \ curl -s -L https://raw.githubusercontent.com/c9/install/master/link.sh | bash; \ - ${C9SDK_PATH}/scripts/install-sdk.sh; \ + ${C9SDK_PATH}/scripts/install-sdk.sh >/dev/null; \ \ # Cleanup + # This saves ~30MB of space. c9 throws some non-critical errors during startup (but still works). + # TODO: may need to revise this rm -rf ${C9SDK_PATH}/.git; \ npm cache clean --force; \ sudo apt-get purge -y --auto-remove -o APT::AutoRemove::RecommendsImportant=false $buildDeps >/dev/null; \ From 9db369487d7a46c260f40f567a50e2cf13651a55 Mon Sep 17 00:00:00 2001 From: Leonid Makarov Date: Sat, 14 Jul 2018 00:10:40 -0700 Subject: [PATCH 43/45] Use the latest develop version of Docksal in tests --- .travis.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index d21c5488..b88586fe 100644 --- a/.travis.yml +++ b/.travis.yml @@ -7,7 +7,7 @@ env: global: - REPO=docksal/cli - LATEST_VERSION=7.2 - - DOCKSAL_VERSION=master + - DOCKSAL_VERSION=develop matrix: - VERSION=5.6 - VERSION=7.0 @@ -19,6 +19,7 @@ before_install: - sudo apt-get install libfcgi0ldbl # cgi-fcgi binary used in tests install: + # Install Docksal to have a matching versions of Docker on the build host - curl -fsSL https://get.docksal.io | DOCKSAL_VERSION=${DOCKSAL_VERSION} bash - fin version - fin sysinfo From b18f4c42be48540fb73ed495f7358fa9e0bb8155 Mon Sep 17 00:00:00 2001 From: Leonid Makarov Date: Mon, 16 Jul 2018 12:00:29 -0700 Subject: [PATCH 44/45] Added informational output in docker-push.sh --- scripts/docker-push.sh | 3 +++ 1 file changed, 3 insertions(+) diff --git a/scripts/docker-push.sh b/scripts/docker-push.sh index 623b51ec..25ca4819 100755 --- a/scripts/docker-push.sh +++ b/scripts/docker-push.sh @@ -37,10 +37,12 @@ tag_and_push () local target=$2 # Base image + echo "Pushing ${target} image ..." docker tag ${source} ${target} docker push ${target} # Cloud9 flavor + echo "Pushing ${target}-ide image ..." docker tag ${source}-ide ${target}-ide docker push ${target}-ide } @@ -76,6 +78,7 @@ tag_and_push ${REPO}:build-${VERSION} ${REPO}:${IMAGE_TAG} # Special case for the "latest" tag # Push (base image only) on stable and release builds if is_latest && (is_stable || is_release); then + echo "Pushing ${REPO}:${IMAGE_TAG_LATEST} image ..." docker tag ${REPO}:build-${VERSION} ${REPO}:${IMAGE_TAG_LATEST} docker push ${REPO}:${IMAGE_TAG_LATEST} fi From 2d54c67a26af0fed6ba08fd388a0ae536ef069b3 Mon Sep 17 00:00:00 2001 From: Leonid Makarov Date: Mon, 16 Jul 2018 12:00:52 -0700 Subject: [PATCH 45/45] Split binaries tests --- tests/test.bats | 61 +++++++++++++++++++++++++++++++++++++++++-------- 1 file changed, 51 insertions(+), 10 deletions(-) diff --git a/tests/test.bats b/tests/test.bats index 193e0cbb..13b0f915 100755 --- a/tests/test.bats +++ b/tests/test.bats @@ -149,7 +149,7 @@ _healthcheck_wait () make clean } -@test "Check binaries and versions" { +@test "Check PHP tools and versions" { [[ $SKIP == 1 ]] && skip ### Setup ### @@ -191,26 +191,67 @@ _healthcheck_wait () [[ ${status} == 0 ]] unset output - # Check Blackfire CLI version - run docker exec -u docker "$NAME" bash -lc 'blackfire version | grep "^blackfire ${BLACKFIRE_VERSION} "' + # Check Terminus version + run docker exec -u docker "$NAME" bash -lc 'terminus --version | grep "^Terminus ${TERMINUS_VERSION}$"' [[ ${status} == 0 ]] unset output - # Check mhsendmail (does not have a flag to report its versions...) - run docker exec -u docker "$NAME" which mhsendmail - echo "$output" | grep "/usr/local/bin/mhsendmail" + # Check Platform CLI version + run docker exec -u docker "$NAME" bash -lc 'platform --version | grep "Platform.sh CLI ${PLATFORMSH_CLI_VERSION}"' + [[ ${status} == 0 ]] unset output - # Check Terminus version - run docker exec -u docker "$NAME" bash -lc 'terminus --version | grep "^Terminus ${TERMINUS_VERSION}$"' + ### Cleanup ### + make clean +} + +@test "Check NodeJS tools and versions" { + #[[ $SKIP == 1 ]] && skip + + ### Setup ### + make start + _healthcheck_wait + + ### Tests ### + + # nvm + run docker exec -u docker "$NAME" bash -lc 'nvm --version | grep "${NVM_VERSION}"' [[ ${status} == 0 ]] unset output - # Check Platform CLI version - run docker exec -u docker "$NAME" bash -lc 'platform --version | grep "Platform.sh CLI ${PLATFORMSH_CLI_VERSION}"' + # nodejs + run docker exec -u docker "$NAME" bash -lc 'node --version | grep "${NODE_VERSION}"' [[ ${status} == 0 ]] unset output + # yarn + run docker exec -u docker "$NAME" bash -lc 'yarn --version | grep "${YARN_VERSION}"' + [[ ${status} == 0 ]] + unset output + + ### Cleanup ### + make clean +} + +@test "Check misc tools and versions" { + [[ $SKIP == 1 ]] && skip + + ### Setup ### + make start + _healthcheck_wait + + ### Tests ### + + # Check Blackfire CLI version + run docker exec -u docker "$NAME" bash -lc 'blackfire version | grep "^blackfire ${BLACKFIRE_VERSION} "' + [[ ${status} == 0 ]] + unset output + + # Check mhsendmail (does not have a flag to report its versions...) + run docker exec -u docker "$NAME" which mhsendmail + echo "$output" | grep "/usr/local/bin/mhsendmail" + unset output + ### Cleanup ### make clean }