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

[BUG] After npm install in docker container GitHub npm packages are not building correctly, but on local it is ok. #4385

Closed
2 tasks done
kczereczon opened this issue Feb 8, 2022 · 3 comments
Labels
Bug thing that needs fixing Needs Triage needs review for next steps Release 8.x work is associated with a specific npm 8 release

Comments

@kczereczon
Copy link

kczereczon commented Feb 8, 2022

Is there an existing issue for this?

  • I have searched the existing issues

This issue exists in the latest npm version

  • I am using the latest npm

Current Behavior

Description of issue

Currently I'm working on EspoCRM extension. In one of step of building extension template I have to build EspoCRM core system. Package.json file of this framework contains couple of custom npm repositories like git://github.com/yurikuzn/bull.git.

After npm install in docker container console.error occurs with the information that the Bull.js is missing, and node_modules/bullbone/disc directory is missing.
After npm install on local machine dist folder is present.

During the npm install on docker container any errors occurs.

What I tried

Changed architecture of docker container from arm64 to linux/amd64
Set NODE_ENV to development in docker container

Files

package.json file
Dockerfile

FROM --platform=linux/amd64 php:7.3-apache

ARG user=user
ARG uid=1000

RUN useradd -G www-data,root -u $uid -d /home/$user $user
RUN mkdir -p /home/$user/.composer && \
    chown -R $user:$user /home/$user 

RUN apt-get update

### Install OS tools
RUN apt-get update && apt-get install --yes curl git libmcrypt-dev libreadline-dev libzip-dev

RUN apt-get install python -y

### Install PHP extras
RUN set -ex; \
    \
    aptMarkList="$(apt-mark showmanual)"; \
    \
    apt-get update; \
    apt-get install -y --no-install-recommends \
        libjpeg-dev \
        libpng-dev \
        libzip-dev \
        libxml2-dev \
        libc-client-dev \
        libkrb5-dev \
        libldb-dev \
        libldap2-dev \
        libzmq3-dev \
        zlib1g-dev \
    ; \
ln -s /usr/lib/x86_64-linux-gnu/libldap.so /usr/lib/libldap.so \
&& ln -s /usr/lib/x86_64-linux-gnu/liblber.so /usr/lib/liblber.so ; \
    \
# Install php-zmq
    cd /usr; \
    curl -fSL https://github.com/zeromq/php-zmq/archive/e0db82c3286da81fa8945894dd10125a528299e4.tar.gz -o php-zmq.tar.gz; \
    tar -zxf php-zmq.tar.gz; \
    cd php-zmq*; \
    phpize && ./configure; \
    make; \
    make install; \
    cd .. && rm -rf php-zmq*; \
# END: Install php-zmq
    \
    docker-php-ext-install pdo_mysql; \
    docker-php-ext-install zip; \
    docker-php-ext-configure gd --with-png-dir=/usr --with-jpeg-dir=/usr; \
    docker-php-ext-install gd; \
    docker-php-ext-configure imap --with-kerberos --with-imap-ssl; \
    docker-php-ext-install imap; \
    docker-php-ext-configure ldap --with-libdir=lib; \
    docker-php-ext-install ldap; \
    docker-php-ext-install exif; \
    docker-php-ext-enable zmq; \
    \
# reset a list of apt-mark
    apt-mark auto '.*' > /dev/null; \
    apt-mark manual $aptMarkList; \
    ldd "$(php -r 'echo ini_get("extension_dir");')"/*.so \
        | awk '/=>/ { print $3 }' \
        | sort -u \
        | xargs -r dpkg-query -S \
        | cut -d: -f1 \
        | sort -u \
        | xargs -rt apt-mark manual; \
    \
    apt-get purge -y --auto-remove -o APT::AutoRemove::RecommendsImportant=false

# Install required libs
RUN set -ex; \
    apt-get install -y --no-install-recommends \
        unzip \
        busybox-static \
    ; \
    rm -rf /var/lib/apt/lists/*; \
    \
    mkdir -p /var/spool/cron/crontabs; \
    echo '* * * * * cd /var/www/html; /usr/local/bin/php -f cron.php > /dev/null 2>&1' > /var/spool/cron/crontabs/www-data

# php.ini
RUN { \
	echo 'expose_php = Off'; \
	echo 'display_errors = Off'; \
	echo 'display_startup_errors = Off'; \
	echo 'log_errors = On'; \
	echo 'memory_limit=256M'; \
	echo 'max_execution_time=180'; \
	echo 'max_input_time=180'; \
	echo 'post_max_size=30M'; \
	echo 'upload_max_filesize=30M'; \
	echo 'date.timezone=UTC'; \
    echo 'allow_url_fopen=1'; \
    echo 'allow_url_include=1' ;\
} > ${PHP_INI_DIR}/conf.d/espocrm.ini

ENV XDEBUG_VERSION=2.9.2

RUN pecl install xdebug-${XDEBUG_VERSION};

RUN { \
        echo "xdebug.mode=debug"; \
        echo "xdebug.remote_enable=1"; \
        echo "xdebug.remote_host=host.docker.internal"; \
        echo "xdebug.remote_connect_back=0"; \
        echo "xdebug.idekey=\"VSCODE\""; \
        echo "xdebug.remote_log=/var/www/html/logs/xdebug.log"; \
        echo "xdebug.start_with_request=yes"; \
        echo "xdebug.client_port=9000"; \
        echo "xdebug.remote_autostart=1"; \
} > ${PHP_INI_DIR}/conf.d/docker-php-ext-xdebug.ini;

RUN docker-php-ext-enable xdebug;
RUN docker-php-ext-install bcmath;

### Install Composer
RUN php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');" \
    && php composer-setup.php \
    && php -r "unlink('composer-setup.php');" \
    && mv composer.phar /usr/bin/composer \
    && chmod +x /usr/bin/composer

### Installl Node
RUN curl -sL https://deb.nodesource.com/setup_14.x | bash
RUN apt-get install --yes nodejs

RUN npm install gulp bower -g
RUN npm install grunt -g
WORKDIR /var/www/html

RUN a2enmod rewrite;

RUN npm install

Expected Behavior

Npm install in docker container should install the same packages like on the local machine.

Steps To Reproduce

  1. Fetch https://github.com/espocrm/espocrm/tree/stable on docker machine with npm
  2. run npm install inside docker
  3. node_modules/bullbone/dist is missing

Environment

  • npm: 8.4.1
  • Node.js: v14.19.0
  • OS Name: Docker: Linux caeda9ccc744 5.10.76-linuxkit #1 SMP PREEMPT Mon Nov 8 11:22:26 UTC 2021 x86_64 GNU/Linux
  • System Model Name: Macbook Pro
  • npm config:
; node bin location = /usr/bin/node
; cwd = /var/www/html
; HOME = /root
@kczereczon kczereczon added Bug thing that needs fixing Needs Triage needs review for next steps Release 8.x work is associated with a specific npm 8 release labels Feb 8, 2022
@fritzy
Copy link
Contributor

fritzy commented Feb 16, 2022

I noticed the package-lock.json is out of date. Can you run npm install manually in the docker image? What is indicating that these files are missing?

@wraithgar
Copy link
Member

Can you inspect the logs on the npm install to be sure that all the deps are installing? The fact that it's a git reference that isn't installing could mean that git ssh isn't working from inside your docker container.

@kczereczon
Copy link
Author

kczereczon commented Mar 17, 2022

I've tried to recreate an error for you to get the logs, but during that the error about PhantomJS and missing a build for my arch occurs (default arm64 arch was selected at that moment). I've changed platform to linux/amd64 and it seems to built with all dependencies (i tried this before). I will write at this thread if the issue get back.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug thing that needs fixing Needs Triage needs review for next steps Release 8.x work is associated with a specific npm 8 release
Projects
None yet
Development

No branches or pull requests

3 participants