skip to Main Content

I’m new with docker, and i try to "dockerise" an existing symfony project. To begin this i’ve created only a Dockerfile in my symfony project that i frequently test using docker build . command.
until the part of my dockerfile where

RUN cd /var/www && 
    composer install && 
    npm install && 
    npm run build

the command docker build . works well. But when i reach this part i obtain this error :

=> ERROR [8/9] RUN cd /var/www &&     composer install &&     npm install &&     npm run build                                                                                    8.9s
------
 > [8/9] RUN cd /var/www &&     composer install &&     npm install &&     npm run build:
#14 0.419 Do not run Composer as root/super user! See https://getcomposer.org/root for details
#14 0.462 Installing dependencies from lock file (including require-dev)
#14 0.462 Verifying lock file contents can be installed on current platform.
#14 0.469 Package operations: 3 installs, 0 updates, 0 removals
#14 0.470     Failed to download symfony/polyfill-mbstring from dist: The zip extension and unzip/7z commands are both missing, skipping.
#14 0.470 Your command-line PHP is using multiple ini files. Run `php --ini` to show them.
#14 0.470     Now trying to download from source
#14 0.472   - Syncing symfony/polyfill-mbstring (v1.26.0) into cache
#14 1.791     Failed to download symfony/polyfill-ctype from dist: The zip extension and unzip/7z commands are both missing, skipping.
#14 1.791 Your command-line PHP is using multiple ini files. Run `php --ini` to show them.
#14 1.791     Now trying to download from source
#14 1.791   - Syncing symfony/polyfill-ctype (v1.26.0) into cache
#14 2.467     Failed to download twig/twig from dist: The zip extension and unzip/7z commands are both missing, skipping.
#14 2.467 Your command-line PHP is using multiple ini files. Run `php --ini` to show them.
#14 2.467     Now trying to download from source
#14 2.467   - Syncing twig/twig (v3.4.1) into cache
#14 4.683     0 [>---------------------------]    0 [->--------------------------]
#14 4.684   - Installing symfony/polyfill-mbstring (v1.26.0): Cloning 9344f9cb97 from cache
#14 4.730   - Installing symfony/polyfill-ctype (v1.26.0): Cloning 6fd1b9a79f from cache
#14 4.774   - Installing twig/twig (v3.4.1): Cloning e939eae923 from cache
#14 5.154     0 [>---------------------------]    0 [->--------------------------]
#14 5.277 Generating autoload files
#14 5.278 3 packages you are using are looking for funding.
#14 5.278 Use the `composer fund` command to find out more!
#14 8.457
#14 8.457 up to date, audited 191 packages in 3s
#14 8.469
#14 8.469 13 vulnerabilities (2 moderate, 8 high, 3 critical)
#14 8.469
#14 8.469 To address issues that do not require attention, run:
#14 8.469   npm audit fix
#14 8.469
#14 8.469 To address all issues (including breaking changes), run:
#14 8.469   npm audit fix --force
#14 8.469
#14 8.469 Run `npm audit` for details.
#14 8.812 npm ERR! missing script: build
#14 8.828
#14 8.828 npm ERR! A complete log of this run can be found in:
#14 8.828 npm ERR!     /root/.npm/_logs/2022-06-13T20_28_53_643Z-debug.log
------
executor failed running [/bin/sh -c cd /var/www &&     composer install &&     npm install &&     npm run build]: exit code: 1

I don’t know if it is usefull to share all the error but i’ve did it if it is.

And here is my code in my Dockerfile :

FROM php:8.1-apache

ADD https://github.com/mlocati/docker-php-extension-installer/releases/latest/download/install-php-extensions /usr/local/bin/

RUN chmod +x /usr/local/bin/install-php-extensions && 
    install-php-extensions pdo_mysql

RUN curl -sSk https://getcomposer.org/installer | php -- --disable-tls && 
   mv composer.phar /usr/local/bin/composer

# install nodejs

RUN apt-get update && apt-get upgrade -y && 
    apt-get install -y nodejs 
    npm

COPY . /var/www/

COPY ./docker/apache.conf /etc/apache2/sites-available/000-default.conf

RUN cd /var/www && 
    composer install && 
    npm install && 
    npm run build

WORKDIR /var/www/

I don’t know how to solve this error in order to my npm packages can be uploaded in my docker stack. I’m sorry if this question seems to be stupid but i’m not familiar with docker.
Thanks in advance to anyone who takes the time to answer my question.

edit :
after replaced npm run build by npm run watch what corresponding to the content of package.json in script the new log is :

=> ERROR [8/9] RUN cd /var/www &&     composer install &&     npm install &&     npm run watch                                                                                   11.7s
------
 > [8/9] RUN cd /var/www &&     composer install &&     npm install &&     npm run watch:
#14 0.871 Do not run Composer as root/super user! See https://getcomposer.org/root for details
#14 0.957 Installing dependencies from lock file (including require-dev)
#14 0.958 Verifying lock file contents can be installed on current platform.
#14 0.974 Package operations: 3 installs, 0 updates, 0 removals
#14 0.975     Failed to download symfony/polyfill-mbstring from dist: The zip extension and unzip/7z commands are both missing, skipping.
#14 0.975 Your command-line PHP is using multiple ini files. Run `php --ini` to show them.
#14 0.975     Now trying to download from source
#14 0.980   - Syncing symfony/polyfill-mbstring (v1.26.0) into cache
#14 1.768     Failed to download symfony/polyfill-ctype from dist: The zip extension and unzip/7z commands are both missing, skipping.
#14 1.768 Your command-line PHP is using multiple ini files. Run `php --ini` to show them.
#14 1.768     Now trying to download from source
#14 1.768   - Syncing symfony/polyfill-ctype (v1.26.0) into cache
#14 2.482     Failed to download twig/twig from dist: The zip extension and unzip/7z commands are both missing, skipping.
#14 2.482 Your command-line PHP is using multiple ini files. Run `php --ini` to show them.
#14 2.482     Now trying to download from source
#14 2.482   - Syncing twig/twig (v3.4.1) into cache
#14 5.854     0 [>---------------------------]    0 [->--------------------------]
#14 5.858   - Installing symfony/polyfill-mbstring (v1.26.0): Cloning 9344f9cb97 from cache
#14 5.962   - Installing symfony/polyfill-ctype (v1.26.0): Cloning 6fd1b9a79f from cache
#14 6.040   - Installing twig/twig (v3.4.1): Cloning e939eae923 from cache
#14 6.878     0 [>---------------------------]    0 [->--------------------------]
#14 7.167 Generating autoload files
#14 7.174 3 packages you are using are looking for funding.
#14 7.174 Use the `composer fund` command to find out more!
#14 10.95
#14 10.95 up to date, audited 191 packages in 3s
#14 10.98
#14 10.98 13 vulnerabilities (2 moderate, 8 high, 3 critical)
#14 10.98
#14 10.98 To address issues that do not require attention, run:
#14 10.98   npm audit fix
#14 10.98
#14 10.98 To address all issues (including breaking changes), run:
#14 10.98   npm audit fix --force
#14 10.98
#14 10.98 Run `npm audit` for details.
#14 11.51
#14 11.51 > [email protected] watch
#14 11.51 > node-sass -w style -o public/style
#14 11.51
#14 11.52 /var/www/node_modules/.bin/node-sass: 1: ../node-sass/bin/node-sass: not found
#14 11.53 npm ERR! code 127
#14 11.53 npm ERR! path /var/www
#14 11.53 npm ERR! command failed
#14 11.53 npm ERR! command sh -c node-sass -w style -o public/style
#14 11.56
#14 11.56 npm ERR! A complete log of this run can be found in:
#14 11.56 npm ERR!     /root/.npm/_logs/2022-06-13T21_10_42_941Z-debug.log
------
executor failed running [/bin/sh -c cd /var/www &&     composer install &&     npm install &&     npm run watch]: exit code: 127

2

Answers


  1. NPM says "npm ERR! missing script: build"
    its looks loke you have no instructions for "build" when do "npm run build"
    try to check your package.json file, it may looks like this:

    "scripts": {
        "dev": "...",
        "build": "...",
        "test": "..."
      },
    
    Login or Signup to reply.
  2. To run

    npm run build
    

    You must have a package.json file with a

      "scripts": {
         "build": "...",
      }
    

    instruction in it.

    Do you have the package.json file in your project? Does it have the "build" script in it?

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search