Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

composer config hangs #3383

Closed
zishiguo opened this issue May 6, 2023 · 1 comment
Closed

composer config hangs #3383

zishiguo opened this issue May 6, 2023 · 1 comment

Comments

@zishiguo
Copy link

zishiguo commented May 6, 2023

Description:

docker-compose build workspace hangs as follows

=> CACHED [ 65/111] RUN if [ false = true ]; then  composer global require "laravel/installer" ;fi                                                                                                    0.0s
 => [ 66/111] RUN if [ https://mirrors.aliyun.com/composer/ ]; then     composer config -g repo.packagist composer https://mirrors.aliyun.com/composer/ ;fi                                          257.9s

There are two point about composer config in the Dockerfile of workspace. The first is successful,but the Second hangs.
the difference is the first's USER is laradock, the second's USER is root.

Dockerfile as follows

###########################################################################
# Composer:
###########################################################################

USER root

# Add the composer.json
COPY ./composer.json /home/laradock/.composer/composer.json

# Add the auth.json for magento 2 credentials
COPY ./auth.json /home/laradock/.composer/auth.json

# Make sure that ~/.composer belongs to laradock
RUN chown -R laradock:laradock /home/laradock/.composer

# Export composer vendor path
RUN echo "" >> ~/.bashrc && \
    echo 'export PATH="$HOME/.composer/vendor/bin:$PATH"' >> ~/.bashrc

# Update composer
ARG COMPOSER_VERSION=2
ENV COMPOSER_VERSION ${COMPOSER_VERSION}
RUN set -eux; \
      if [ "$COMPOSER_VERSION" = "1" ] || [ "$COMPOSER_VERSION" = "2" ]; then \
          composer self-update --${COMPOSER_VERSION}; \
      else \
          composer self-update ${COMPOSER_VERSION}; \
      fi

USER laradock

# Check if global install need to be ran
ARG COMPOSER_GLOBAL_INSTALL=false
ENV COMPOSER_GLOBAL_INSTALL ${COMPOSER_GLOBAL_INSTALL}

RUN if [ ${COMPOSER_GLOBAL_INSTALL} = true ]; then \
    # run the install
    composer global install \
;fi

# Check if auth file is disabled
ARG COMPOSER_AUTH_JSON=false
ENV COMPOSER_AUTH_JSON ${COMPOSER_AUTH_JSON}

RUN if [ ${COMPOSER_AUTH_JSON} = false ]; then \
    # remove the file
    rm /home/laradock/.composer/auth.json \
;fi

ARG COMPOSER_REPO_PACKAGIST
ENV COMPOSER_REPO_PACKAGIST ${COMPOSER_REPO_PACKAGIST}

RUN if [ ${COMPOSER_REPO_PACKAGIST} ]; then \
    composer config -g repo.packagist composer ${COMPOSER_REPO_PACKAGIST} \
;fi

# Export composer vendor path
RUN echo "" >> ~/.bashrc && \
    echo 'export PATH="~/.composer/vendor/bin:$PATH"' >> ~/.bashrc

...

###########################################################################
# Laravel Installer:
###########################################################################

USER laradock

ARG INSTALL_LARAVEL_INSTALLER=false

RUN if [ ${INSTALL_LARAVEL_INSTALLER} = true ]; then \
    # Install the Laravel Installer
    composer global require "laravel/installer" \
;fi

USER root

ARG COMPOSER_REPO_PACKAGIST
ENV COMPOSER_REPO_PACKAGIST ${COMPOSER_REPO_PACKAGIST}

RUN if [ ${COMPOSER_REPO_PACKAGIST} ]; then \
    composer config -g repo.packagist composer ${COMPOSER_REPO_PACKAGIST} \
;fi

Expected Behavior:

build successfully

Context information:

Output of git rev-parse HEAD

baa65a6e9e835f049654939bc7989f0fcd1f18dc

Output of docker version

Client:
 Cloud integration: v1.0.31
 Version:           23.0.5
 API version:       1.42
 Go version:        go1.19.8
 Git commit:        bc4487a
 Built:             Wed Apr 26 16:12:52 2023
 OS/Arch:           darwin/arm64
 Context:           default

Server: Docker Desktop 4.19.0 (106363)
 Engine:
  Version:          23.0.5
  API version:      1.42 (minimum version 1.12)
  Go version:       go1.19.8
  Git commit:       94d3ad6
  Built:            Wed Apr 26 16:17:14 2023
  OS/Arch:          linux/arm64
  Experimental:     false
 containerd:
  Version:          1.6.20
  GitCommit:        2806fc1057397dbaeefbea0e4e17bddfbd388f38
 runc:
  Version:          1.1.5
  GitCommit:        v1.1.5-0-gf19387a
 docker-init:
  Version:          0.19.0
  GitCommit:        de40ad0

Output of docker-compose version

Docker Compose version v2.17.3

System info: Mac, Windows or Linux. Include which disto/version

Mac M2

Steps to reproduce the issue:

  1. docker-compose build workspace

Stacktrace & Additional info:

.env file as follows

CHANGE_SOURCE=true

### WORKSPACE #############################################

WORKSPACE_BASE_IMAGE_TAG_PREFIX=latest
WORKSPACE_COMPOSER_GLOBAL_INSTALL=true
WORKSPACE_COMPOSER_VERSION=1
WORKSPACE_COMPOSER_AUTH_JSON=false
WORKSPACE_COMPOSER_REPO_PACKAGIST=https://mirrors.aliyun.com/composer/
...
WORKSPACE_INSTALL_LARAVEL_INSTALLER=false
[+] Building 5.7s (69/115)
 => CACHED [ 23/111] RUN if [ false = true ]; then     apt-get -qq -y install mysql-client &&     curl -fsSL -o /usr/local/bin/drush https://github.com/drush-ops/drush/releases/download/8.4.6/drush  0.0s
[+] Building 5.8s (69/115)
 => CACHED [ 23/111] RUN if [ false = true ]; then     apt-get -qq -y install mysql-client &&     curl -fsSL -o /usr/local/bin/drush https://github.com/drush-ops/drush/releases/download/8.4.6/drush  0.0s
[+] Building 6.0s (69/115)
 => CACHED [ 25/111] RUN set -eux;     if [ false = true ]; then       apt-get -yqq install php7.2-bz2;     fi;     if [ false = true ]; then       apt-get -yqq install php7.2-gmp;     fi;     if [  0.0s
[+] Building 323.5s (70/115)
 => [internal] load build definition from Dockerfile                                                                                                                                                   0.0s
 => => transferring dockerfile: 68.43kB                                                                                                                                                                0.0s
 => [internal] load .dockerignore                                                                                                                                                                      0.0s
 => => transferring context: 2B                                                                                                                                                                        0.0s
 => [internal] load metadata for docker.io/laradock/workspace:latest-7.2                                                                                                                               0.0s
 => [internal] load build context                                                                                                                                                                      0.0s
 => => transferring context: 446B                                                                                                                                                                      0.0s
 => [  1/111] FROM docker.io/laradock/workspace:latest-7.2                                                                                                                                             0.0s
 => CACHED [  2/111] RUN if [ true = true ]; then     sed -i 's/ports.ubuntu.com/mirrors.tuna.tsinghua.edu.cn/g' /etc/apt/sources.list;     sed -i 's/archive.ubuntu.com/mirrors.aliyun.com/g' /etc/a  0.0s
 => CACHED [  3/111] RUN set -xe;     apt-get update -yqq &&     pecl channel-update pecl.php.net &&     groupadd -g 1000 laradock &&     useradd -l -u 1000 -g laradock -m laradock -G docker_env &&  0.0s
 => CACHED [  4/111] RUN ln -snf /usr/share/zoneinfo/PRC /etc/localtime && echo PRC > /etc/timezone                                                                                                    0.0s
 => CACHED [  5/111] COPY ./aliases.sh /root/aliases.sh                                                                                                                                                0.0s
 => CACHED [  6/111] COPY ./aliases.sh /home/laradock/aliases.sh                                                                                                                                       0.0s
 => CACHED [  7/111] RUN sed -i 's/\r//' /root/aliases.sh &&     sed -i 's/\r//' /home/laradock/aliases.sh &&     chown laradock:laradock /home/laradock/aliases.sh &&     echo "" >> ~/.bashrc &&     0.0s
 => CACHED [  8/111] RUN echo "" >> ~/.bashrc &&     echo "# Load Custom Aliases" >> ~/.bashrc &&     echo "source ~/aliases.sh" >> ~/.bashrc &&    echo "" >> ~/.bashrc                               0.0s
 => CACHED [  9/111] COPY ./composer.json /home/laradock/.composer/composer.json                                                                                                                       0.0s
 => CACHED [ 10/111] COPY ./auth.json /home/laradock/.composer/auth.json                                                                                                                               0.0s
 => CACHED [ 11/111] RUN chown -R laradock:laradock /home/laradock/.composer                                                                                                                           0.0s
 => CACHED [ 12/111] RUN echo "" >> ~/.bashrc &&     echo 'export PATH="$HOME/.composer/vendor/bin:$PATH"' >> ~/.bashrc                                                                                0.0s
 => CACHED [ 13/111] RUN set -eux;       if [ "1" = "1" ] || [ "1" = "2" ]; then           composer self-update --1;       else           composer self-update 1;       fi                             0.0s
 => CACHED [ 14/111] RUN if [ true = true ]; then     composer global install ;fi                                                                                                                      0.0s
 => CACHED [ 15/111] RUN if [ false = false ]; then     rm /home/laradock/.composer/auth.json ;fi                                                                                                      0.0s
 => CACHED [ 16/111] RUN if [ https://mirrors.aliyun.com/composer/ ]; then     composer config -g repo.packagist composer https://mirrors.aliyun.com/composer/ ;fi                                     0.0s
 => CACHED [ 17/111] RUN echo "" >> ~/.bashrc &&     echo 'export PATH="~/.composer/vendor/bin:$PATH"' >> ~/.bashrc                                                                                    0.0s
 => CACHED [ 18/111] RUN echo "" >> ~/.bashrc &&     echo 'export PATH="/var/www/vendor/bin:$PATH"' >> ~/.bashrc                                                                                       0.0s
 => CACHED [ 19/111] COPY ./crontab /etc/cron.d                                                                                                                                                        0.0s
 => CACHED [ 20/111] RUN chmod -R 644 /etc/cron.d                                                                                                                                                      0.0s
 => CACHED [ 21/111] COPY ./ca-certificates/* /usr/local/share/ca-certificates/                                                                                                                        0.0s
 => CACHED [ 22/111] RUN update-ca-certificates                                                                                                                                                        0.0s
 => CACHED [ 23/111] RUN if [ false = true ]; then     apt-get -qq -y install mysql-client &&     curl -fsSL -o /usr/local/bin/drush https://github.com/drush-ops/drush/releases/download/8.4.6/drush  0.0s
 => CACHED [ 24/111] RUN if [ false = true ]; then     curl -fsSL -o /usr/local/bin/wp https://raw.githubusercontent.com/wp-cli/builds/gh-pages/phar/wp-cli.phar | bash &&     chmod +x /usr/local/bi  0.0s
 => CACHED [ 25/111] RUN set -eux;     if [ false = true ]; then       apt-get -yqq install php7.2-bz2;     fi;     if [ false = true ]; then       apt-get -yqq install php7.2-gmp;     fi;     if [  0.0s
 => CACHED [ 26/111] RUN set -eux;     if [ false = true ]; then         apt-get install -yqq libldap2-dev php7.2-ldap;     fi;     if [ false = true ]; then         apt-get install -yqq smbclient   0.0s
 => CACHED [ 27/111] RUN if [ true = true ]; then   apt-get install -yqq pkg-config php-xml php7.2-xml &&   if [ $(php -r "echo PHP_MAJOR_VERSION;") = "8" ] || { [ $(php -r "echo PHP_MAJOR_VERSION;  0.0s
 => CACHED [ 28/111] COPY ./xdebug.ini /etc/php/7.2/cli/conf.d/xdebug.ini                                                                                                                              0.0s
 => CACHED [ 29/111] RUN if [ $(php -r "echo PHP_MAJOR_VERSION;") = "8" ] || { [ $(php -r "echo PHP_MAJOR_VERSION;") = "7" ] && { [ $(php -r "echo PHP_MINOR_VERSION;") = "4" ] || [ $(php -r "echo P  0.0s
 => CACHED [ 30/111] RUN sed -i "s/xdebug.cli_color=0/xdebug.cli_color=1/" /etc/php/7.2/cli/conf.d/xdebug.ini                                                                                          0.0s
 => CACHED [ 31/111] RUN if [ false = true ]; then   if [ $(php -r "echo PHP_MAJOR_VERSION;") = "8" ]  || { [ $(php -r "echo PHP_MAJOR_VERSION;") = "7" ] && [ $(php -r "echo PHP_MINOR_VERSION;") !=  0.0s
 => CACHED [ 32/111] RUN if [ false = true ]; then     apt-get install -y --force-yes php7.2-phpdbg ;fi                                                                                                0.0s
 => CACHED [ 33/111] COPY insecure_id_rsa /tmp/id_rsa                                                                                                                                                  0.0s
 => CACHED [ 34/111] COPY insecure_id_rsa.pub /tmp/id_rsa.pub                                                                                                                                          0.0s
 => CACHED [ 35/111] RUN if [ false = true ]; then     rm -f /etc/service/sshd/down &&     cat /tmp/id_rsa.pub >> /root/.ssh/authorized_keys         && cat /tmp/id_rsa.pub >> /root/.ssh/id_rsa.pub   0.0s
 => CACHED [ 36/111] RUN if [ false = true ]; then     apt-get install -yqq pkg-config &&     if [ $(php -r "echo PHP_MAJOR_VERSION;") = "5" ]; then       pecl install mongo;       echo "extension=  0.0s
 => CACHED [ 37/111] RUN if [ false = true ]; then     apt-get install -yqq librabbitmq-dev &&     if [ $(php -r "echo PHP_MAJOR_VERSION;") = "8" ]; then       printf "\n" | pecl install amqp-1.11.  0.0s
 => CACHED [ 38/111] RUN if [ false = true ]; then     if [ $(php -r "echo PHP_MAJOR_VERSION;") = "8" ]; then       echo "PHP Driver for Cassandra is not supported for PHP 8.0.";     else       apt  0.0s
 => CACHED [ 39/111] RUN if [ false = true ]; then     add-apt-repository -y ppa:ondrej/pkg-gearman &&     apt-get update &&     apt-get -yqq install php-gearman ;fi                                  0.0s
 => CACHED [ 40/111] RUN if [ true = true ]; then     apt-get update     && apt-get install -yqq php7.2-redis ;fi                                                                                      0.0s
 => CACHED [ 41/111] RUN set -eux;     if [ false = true ]; then       if [ $(php -r "echo PHP_MAJOR_VERSION;") = "5" ]; then         echo '' | pecl -q install swoole-2.0.10;       elif [ $(php -r   0.0s
 => CACHED [ 42/111] RUN set -eux;     if [ false = true ]; then       if [ $(php -r "echo PHP_MAJOR_VERSION;") != "5" ]; then         echo '' | pecl -q install xlswriter &&         echo "extension  0.0s
 => CACHED [ 43/111] RUN if [ "false" = true ]; then     if [ $(php -r "echo PHP_MAJOR_VERSION;") = "7" ]; then       pecl install taint &&       echo "extension=taint.so" >> /etc/php/7.2/mods-avai  0.0s
 => CACHED [ 44/111] RUN if [ true = true ]; then     apt-get -yqq install libpng16-16 ;fi                                                                                                             0.0s
 => CACHED [ 45/111] RUN if [ false = true ]; then     if [ $(php -r "echo PHP_MAJOR_VERSION;") = "5" ]; then       pecl -q install inotify-0.1.6 &&       echo "extension=inotify.so" >> /etc/php/7.  0.0s
 => CACHED [ 46/111] RUN if [ true = true ]; then     if [ $(php -r "echo PHP_MAJOR_VERSION;") != "5" ]; then         apt-get -yqq install wget &&         wget https://github.com/nikic/php-ast/arch  0.0s
 => CACHED [ 47/111] RUN if [ false = true ]; then     apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 47FE03C1     && add-apt-repository -y ppa:hadret/fswatch     || apt-get update -yqq    0.0s
 => CACHED [ 48/111] RUN if [ false = true ]; then     apt-get install -yqq graphviz ;fi                                                                                                               0.0s
 => CACHED [ 49/111] RUN if [ false = true ]; then     if [ $(php -r "echo PHP_MAJOR_VERSION;") != "8" ]; then       curl -L -o /tmp/ioncube_loaders_lin_x86-64.tar.gz https://downloads.ioncube.com/  0.0s
 => CACHED [ 50/111] RUN if [ false = true ]; then     apt-get -y install mysql-client &&     curl https://drupalconsole.com/installer -L -o drupal.phar &&     mv drupal.phar /usr/local/bin/drupal   0.0s
 => CACHED [ 51/111] RUN if [ false = true ]; then     mkdir -p /home/laradock/.nvm &&     curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.2/install.sh | bash         && . /home/laradoc  0.0s
 => CACHED [ 52/111] RUN if [ false = true ]; then     echo "" >> ~/.bashrc &&     echo 'export NVM_DIR="$HOME/.nvm"' >> ~/.bashrc &&     echo '[ -s "$NVM_DIR/nvm.sh" ] && . "$NVM_DIR/nvm.sh"  # Th  0.0s
 => CACHED [ 53/111] RUN if [ false = true ]; then     echo "" >> ~/.bashrc &&     echo 'export NVM_DIR="/home/laradock/.nvm"' >> ~/.bashrc &&     echo '[ -s "$NVM_DIR/nvm.sh" ] && . "$NVM_DIR/nvm.  0.0s
 => CACHED [ 54/111] RUN if [ false = true ]; then     find /home/laradock/.nvm -type f -name node -exec ln -s {} /usr/local/bin/node ; &&     NODE_MODS_DIR="/home/laradock/.nvm/versions/node/$(nod  0.0s
 => CACHED [ 55/111] RUN if [  ]; then     . ~/.bashrc && npm config set registry  ;fi                                                                                                                 0.0s
 => CACHED [ 56/111] COPY ./.npmrc /root/.npmrc                                                                                                                                                        0.0s
 => CACHED [ 57/111] COPY ./.npmrc /home/laradock/.npmrc                                                                                                                                               0.0s
 => CACHED [ 58/111] RUN if [ false = true ]; then     echo "" >> ~/.bashrc &&     echo 'export PNPM_HOME="/home/laradock/.local/share/pnpm"' >> ~/.bashrc &&     echo 'export PATH="$PNPM_HOME:$PATH  0.0s
 => CACHED [ 59/111] RUN if [ false = true ]; then     [ -s "/home/laradock/.nvm/nvm.sh" ] && . "/home/laradock/.nvm/nvm.sh" &&     if [ latest = "latest" ]; then         curl -o- -L https://yarnpk  0.0s
 => CACHED [ 60/111] RUN if [ false = true ]; then     echo "" >> ~/.bashrc &&     echo 'export YARN_DIR="/home/laradock/.yarn"' >> ~/.bashrc &&     echo 'export PATH="$YARN_DIR/bin:$PATH"' >> ~/.b  0.0s
 => CACHED [ 61/111] RUN set -xe;   if [ false = true ]; then     apt-get -y install sudo wget &&     if [ $(php -r "echo PHP_MAJOR_VERSION;") = "5" ]; then       curl -L -o /tmp/aerospike-client-p  0.0s
 => CACHED [ 62/111] RUN if [ false = true ]; then   apt-get update && apt-get install --no-install-recommends -y wget   && mkdir /opt/oracle       && cd /opt/oracle       && wget https://github.co  0.0s
 => CACHED [ 63/111] RUN set -xe;   if [ false = true ]; then     add-apt-repository -y ppa:pinepain/libv8-archived     && apt-get update -yqq     && apt-get install -y libv8-5.4 &&     if [ $(php   0.0s
 => CACHED [ 64/111] RUN if [ false = true ]; then     composer global config --no-plugins allow-plugins.kylekatarnls/update-helper true &&     composer global require laravel/envoy ;fi              0.0s
 => CACHED [ 65/111] RUN if [ false = true ]; then  composer global require "laravel/installer" ;fi                                                                                                    0.0s
 => CANCELED [ 66/111] RUN if [ https://mirrors.aliyun.com/composer/ ]; then     composer config -g repo.packagist composer https://mirrors.aliyun.com/composer/ ;fi                                 323.4s
canceled
@zishiguo
Copy link
Author

zishiguo commented May 6, 2023

I can visit youtube. It works after I set CHANGE_SOURCE=false.

@zishiguo zishiguo closed this as completed May 6, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant