I have a “legacy” code (symfony) running on php7.3 and they were using node v6 and gulp for assets.
I want to build a Docker development environment, but I am having problems with node and permissions. In my company, we use LDAP for authentication, so our user id is not 1000, so I need to create a user inside docker with the same host id and gid.
I have it almost working but when I try to install gulp I get this error:
Step 37/47 : RUN npm install -g gulp
---> Running in 607492f81dfe
npm WARN deprecated chokidar@2.1.8: Chokidar 2 does not receive security updates since 2019. Upgrade to chokidar 3 with 15x fewer dependencies
npm WARN deprecated source-map-resolve@0.5.3: See https://github.com/lydell/source-map-resolve#deprecated
npm WARN deprecated source-map-url@0.4.1: See https://github.com/lydell/source-map-url#deprecated
npm WARN deprecated resolve-url@0.2.1: https://github.com/lydell/resolve-url#deprecated
npm WARN deprecated urix@0.1.0: Please see https://github.com/lydell/urix#deprecated
/root/.nvm/versions/node/v6.17.1/bin/gulp -> /root/.nvm/versions/node/v6.17.1/lib/node_modules/gulp/bin/gulp.js
> es5-ext@0.10.59 postinstall /root/.nvm/versions/node/v6.17.1/lib/node_modules/gulp/node_modules/es5-ext
> node -e "try{require('./_postinstall')}catch(e){}"
sh: 1: node: Permission denied
/root/.nvm/versions/node/v6.17.1/lib
`-- (empty)
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@^1.2.7 (node_modules/gulp/node_modules/chokidar/node_modules/fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.2.13: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})
npm ERR! Linux 5.13.0-30-generic
npm ERR! argv "/root/.nvm/versions/node/v6.17.1/bin/node" "/root/.nvm/versions/node/v6.17.1/bin/npm" "install" "-g" "gulp"
npm ERR! node v6.17.1
npm ERR! npm v3.10.10
npm ERR! file sh
npm ERR! code ELIFECYCLE
npm ERR! errno ENOENT
npm ERR! syscall spawn
npm ERR! es5-ext@0.10.59 postinstall: `node -e "try{require('./_postinstall')}catch(e){}"`
npm ERR! spawn ENOENT
npm ERR!
npm ERR! Failed at the es5-ext@0.10.59 postinstall script 'node -e "try{require('./_postinstall')}catch(e){}"'.
npm ERR! Make sure you have the latest version of node.js and npm installed.
npm ERR! If you do, this is most likely a problem with the es5-ext package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR! node -e "try{require('./_postinstall')}catch(e){}"
npm ERR! You can get information on how to open an issue for this project with:
npm ERR! npm bugs es5-ext
npm ERR! Or if that isn't available, you can get their info via:
npm ERR! npm owner ls es5-ext
npm ERR! There is likely additional logging output above.
npm ERR! Please include the following file with any support request:
npm ERR! /usr/src/app/npm-debug.log
npm ERR! code 1
Removing intermediate container 607492f81dfe
The command '/bin/sh -c npm install -g gulp' returned a non-zero code: 1
ERROR: Service 'app' failed to build : Build failed
This is the Dockefile I’m using:
FROM php:7.3-fpm
ARG USER_ID=1000
ARG GROUP_ID=1000
ARG DOCKER_TIMEZONE=${DOCKER_TIMEZONE}
ARG DEBUGMODE=0
ARG FOSJSDUMP=0
ARG TIMEZONE
ENV PS1="\u@\h:\w\\$ "
RUN echo "${DOCKER_TIMEZONE}" > /etc/timezone
RUN useradd -l -u ${USER_ID} -g users appuser
RUN groupmod --gid $GROUP_ID www-data
# 2 Set working directory
WORKDIR /usr/src/app
ENV NODE_VERSION=6.17.1
RUN apt install -y curl
RUN curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.0/install.sh | bash
ENV NVM_DIR=/root/.nvm
RUN . "$NVM_DIR/nvm.sh" && nvm install ${NODE_VERSION}
RUN . "$NVM_DIR/nvm.sh" && nvm use v${NODE_VERSION}
RUN . "$NVM_DIR/nvm.sh" && nvm alias default v${NODE_VERSION}
ENV PATH="/root/.nvm/versions/node/v${NODE_VERSION}/bin/:${PATH}"
RUN node --version
RUN npm --version
RUN apt-get update && apt-get install -y \
gnupg \
git \
curl \
libpng-dev \
libonig-dev \
libxml2-dev \
zip \
unzip \
g++ \
procps \
openssl \
git \
unzip \
zlib1g-dev \
libzip-dev \
libfreetype6-dev \
libpng-dev \
libjpeg-dev \
libicu-dev \
libonig-dev \
libxslt1-dev \
acl \
&& echo 'alias sf="php bin/console"' >> ~/.bashrc
# Clear cache
RUN apt-get clean && rm -rf /var/lib/apt/lists/*
RUN docker-php-ext-install -j$(nproc) \
zip \
exif \
bcmath \
intl \
pcntl \
mysqli \
pdo \
gd \
pdo_mysql \
mbstring \
soap \
opcache \
iconv
# Install Imagick
RUN apt-get update && apt-get install -y \
libmagickwand-dev --no-install-recommends \
&& pecl install imagick \
&& docker-php-ext-enable imagick
# xdebug extensions
RUN if [[ "$DEBUGMODE" = "0" ]] ; \
then \
echo "DEBUG MODE NOT ENABLED"; \
else \
# echo DEGUGMODE $DEBUGMODE \
pecl install xdebug && docker-php-ext-enable xdebug \
; fi
#
# ldap
RUN apt-get install libldap2-dev -y && \
rm -rf /var/lib/apt/lists/* && \
docker-php-ext-configure ldap --with-libdir=lib/x86_64-linux-gnu/ && \
docker-php-ext-install ldap
# Redis
RUN pecl install -o -f redis && rm -rf /tmp/pear && docker-php-ext-enable redis
# Set timezone
RUN ln -snf /usr/share/zoneinfo/${TIMEZONE} /etc/localtime && echo ${TIMEZONE} > /etc/timezone \
&& printf '[PHP]\ndate.timezone = "%s"\n', ${TIMEZONE} > /usr/local/etc/php/conf.d/tzone.ini \
&& "date"
# Install Composer
RUN echo "Install Composer"
RUN composer --version
COPY --from=composer:latest /usr/bin/composer /usr/bin/composer
WORKDIR /usr/src/app
RUN npm install -g gulp
RUN gulp prod
# 8 Copy existing application directory permissions
COPY --chown=appuser:appuser . /usr/src/app
RUN composer install --no-scripts --prefer-dist --no-interaction --optimize-autoloader
RUN php bin/console cache:clear
RUN mkdir -p /usr/src/app/web/uploads
RUN chmod -R 777 /usr/src/app/web/uploads
#RUN chown -R www-data:www-data /usr/src/app
# 9 Change current user
USER appuser
# 10 Expose port 9000 and start php-fpm server
EXPOSE 9000
CMD ["php-fpm", "-F"]
WORKDIR /usr/src/app
Any help or clue?