docker-images-php icon indicating copy to clipboard operation
docker-images-php copied to clipboard

Slim v4 image failed to build with node

Open afdolriski opened this issue 2 years ago • 3 comments

Expected Behavior

Using this Dockerfile:

ARG NODE_VERSION=12
FROM thecodingmachine/php:7.4-v4-slim-fpm

The build should be finished without error and having node 12 installed.

Current Behavior

The build process will produce an error:

npm ERR! Error: EACCES: permission denied, access '/usr/lib/node_modules/npm/node_modules/abbrev'

Possible Solution

I imagine 2 options:

  1. On slim file remove this command:
npm install -g npm
  1. Modify default directory, source: npm

Steps to Reproduce (for bugs)

  1. Use Dockerfile provided above
  2. Run build docker build . -t slim-image

afdolriski avatar Oct 04 '22 18:10 afdolriski

Same issue at me.

ARG NODE_VERSION=18
FROM thecodingmachine/php:8.0-v4-slim-apache
#8 31.07 The following NEW packages will be installed:
#8 31.07   yarn
#8 31.29 0 upgraded, 1 newly installed, 0 to remove and 0 not upgraded.
#8 31.29 Need to get 893 kB of archives.
#8 31.29 After this operation, 5415 kB of additional disk space will be used.
#8 31.29 Get:1 https://dl.yarnpkg.com/debian stable/main amd64 yarn all 1.22.19-1 [893 kB]
#8 31.52 debconf: delaying package configuration, since apt-utils is not installed
#8 31.54 Fetched 893 kB in 0s (2604 kB/s)
#8 31.60 Selecting previously unselected package yarn.
(Reading database ... 17884 files and directories currently installed.)
#8 31.61 Preparing to unpack .../yarn_1.22.19-1_all.deb ...
#8 31.61 Unpacking yarn (1.22.19-1) ...
#8 31.88 Setting up yarn (1.22.19-1) ...
#8 33.02 npm ERR! code EACCES
#8 33.02 npm ERR! syscall rename
#8 33.02 npm ERR! path /usr/lib/node_modules/npm
#8 33.02 npm ERR! dest /usr/lib/node_modules/.npm-qUIFSsiV
#8 33.02 npm ERR! errno -13
#8 33.02 npm ERR! Error: EACCES: permission denied, rename '/usr/lib/node_modules/npm' -> '/usr/lib/node_modules/.npm-qUIFSsiV'
#8 33.02 npm ERR!  [Error: EACCES: permission denied, rename '/usr/lib/node_modules/npm' -> '/usr/lib/node_modules/.npm-qUIFSsiV'] {
#8 33.02 npm ERR!   errno: -13,
#8 33.02 npm ERR!   code: 'EACCES',
#8 33.02 npm ERR!   syscall: 'rename',
#8 33.02 npm ERR!   path: '/usr/lib/node_modules/npm',
#8 33.02 npm ERR!   dest: '/usr/lib/node_modules/.npm-qUIFSsiV'
#8 33.02 npm ERR! }
#8 33.02 npm ERR!
#8 33.02 npm ERR! The operation was rejected by your operating system.
#8 33.02 npm ERR! It is likely you do not have the permissions to access this file as the current user
#8 33.02 npm ERR!
#8 33.02 npm ERR! If you believe this might be a permissions issue, please double-check the
#8 33.02 npm ERR! permissions of the file and its containing directories, or try running
#8 33.02 npm ERR! the command again as root/Administrator.
#8 33.02
#8 33.02 npm ERR! A complete log of this run can be found in:
#8 33.02 npm ERR!     /home/docker/.npm/_logs/2022-10-31T10_23_52_154Z-debug-0.log

f3l1x avatar Oct 31 '22 10:10 f3l1x

For anyone having same problem, you can use this image instead for temporary fix:

FROM thecodingmachine/php:7.4.29-v4-slim-fpm

afdolriski avatar Oct 31 '22 20:10 afdolriski

Hum i think we can just change

ONBUILD RUN if [ -n "$NODE_VERSION" ]; then \
    sudo apt-get update && \
    sudo apt-get install -y --no-install-recommends gnupg && \
    curl -sL https://deb.nodesource.com/setup_${NODE_VERSION}.x | sudo bash - && \
    sudo apt-get update && \
    sudo apt-get install -y --no-install-recommends nodejs && \
    curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | sudo apt-key add - && \
    echo "deb https://dl.yarnpkg.com/debian/ stable main" | sudo tee /etc/apt/sources.list.d/yarn.list && \
    sudo apt-get update && \
    sudo apt-get install -y --no-install-recommends yarn && \
-    if [[ "${NODE_VERSION}" == "10" ]]; then npm install -g npm@^6.14; else npm install -g npm; fi && \
+    if [[ "${NODE_VERSION}" == "10" ]]; then sudo npm install -g npm@^6.14; fi && \
    sudo apt-get clean && \
    sudo rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* /usr/share/doc/*; \
    fi;

I think there are more issue related to npm install but we will more to v5 in few month so maybe we can use this quickfix for instance.

mistraloz avatar Nov 03 '22 10:11 mistraloz