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

Running in npm denied permission #1309

Closed
Brotzka opened this issue Jun 24, 2022 · 2 comments
Closed

Running in npm denied permission #1309

Brotzka opened this issue Jun 24, 2022 · 2 comments
Labels
question Usability question, not directly related to an error with the image

Comments

@Brotzka
Copy link

Brotzka commented Jun 24, 2022

I get the following error message when I try to spin up my service via docker-compose:

service_frontend | npm ERR! code 128

service_frontend | npm ERR! An unknown git error occurred

service_frontend | npm ERR! command git --no-replace-objects clone -b feature/WHITELABEL-212-skeletons-während-der-lad https://bjoernme:***@bitbucket.org/faaren/faaren-ui.git /root/.npm/_cacache/tmp/git-cloneBmjHnf --recurse-submodules --depth=1

service_frontend | npm ERR! fatal: could not create leading directories of '/root/.npm/_cacache/tmp/git-cloneBmjHnf': Permission denied

service_frontend |

service_frontend | npm ERR! A complete log of this run can be found in:

service_frontend | npm ERR! /root/.npm/_logs/2022-06-24T13_42_41_376Z-debug.log

service_frontend exited with code 128

I have tried multiple constellations with in my docker-compose.yml for the user property, starting from root, root:root, node:node, 1000:1000, UID:GID (variables are set to inject my local user id and group id.

The relevant part from my docker-compose.yml:

  service_frontend:
    image: eu.gcr.io/faaren-prod/frontend:latest
    build:
      context: /workspace/faaren-services/frontend
      dockerfile: Dockerfile
      args:
        dev: "true"
    command: bash -c "npm install --save-dev [email protected] && composer install && php artisan octane:start --server=swoole --host=0.0.0.0 --port=8080 --watch"
    container_name: service_frontend
    restart: unless-stopped
    depends_on:
      - mysql8
    ports:
      - "9010:8080"
    user: root
    networks:
      - faaren-services
    environment:
      PHP_IDE_CONFIG: "serverName=serviceFrontend"
    volumes:
      - /workspace/faaren-services/frontend:/var/www/html
      - ./docker-conf/supervisor/supervisord.conf:/etc/supervisor/conf.d/supervisord.conf
      - ./docker-conf/php/debugger.ini:/usr/local/etc/php/conf.d/debugger.ini

This is my local docker image:

###########################################
# GET PHP-FPM-ALPINE IMAGE FROM DOCKERHUB #
###########################################
FROM eu.gcr.io/faaren-prod/frontend-base-image:latest

#######################
# COPY FILES TO IMAGE #
#######################
COPY . /var/www/html

#####################
# DEV ENV SPECIFICS #
#####################
ARG dev=false
RUN if [ ${dev} = "true" ] ; then \
        set -ex \
        && apk add --no-cache $PHPIZE_DEPS \
        && apk add --no-cache npm \
        && apk add --no-cache boost-dev \
        && apk add --no-cache autoconf \
        && apk add --no-cache gcc \
        && apk add --no-cache make \
        && apk add --no-cache g++ \
        && mkdir -p /.npm \
        && mkdir -p /.cache \
        && mkdir -p /.cache/Cypress \
        && mkdir -p /root/.npm/_cacache/tmp/ \
        && chmod 777 -R "/root/.npm/_cacache/tmp/" \
        && chmod 777 -R "/.npm" \
        && chmod 777 -R "/.cache" \
        && chmod 777 -R "/.cache/Cypress" \
        && pecl install xdebug-3.1.0 \
        && docker-php-ext-enable xdebug; \
    fi ;

####################
# COMPOSER INSTALL #
####################
RUN cd /var/www/html && composer install
RUN apk add --no-cache curl
RUN sh -c 'cd /var/www/html && curl -sfL https://raw.githubusercontent.com/lokalise/lokalise-cli-2-go/master/install.sh | sh'
RUN ln -s /var/www/html/bin/lokalise2 /usr/bin/lokalise2

##########################
# START OCTANE WEBSERVER #
##########################
CMD ["php", "artisan", "octane:start", "--server=swoole", "--host=0.0.0.0", "--port=8080"]

And this is our internal base image (which is based on the php:8.1.1-fpm-alpine3.15 image:

###########################################
# GET PHP-FPM-ALPINE IMAGE FROM DOCKERHUB #
###########################################
FROM php:8.1.1-fpm-alpine3.15

##############
# ESSENTIALS #
##############
WORKDIR /var/www/html/

# environment als parameter beim build übergeben
ARG environment=local

# kafka version
ARG LIBRDKAFKA_VERSION=v1.8.2

# GitHub Token
ENV COMPOSER_TOKEN=xxx

################################
# INSTALL GENERAL DEPENDENCIES #
################################
RUN apk add --no-cache --update git \
    curl \
    openssl \
    autoconf \
    gcc \
    make \
    g++ \
    bash \
    supervisor \
    nodejs \
    npm \
    zsh

RUN docker-php-ext-install mysqli pdo pdo_mysql

RUN pecl install swoole-4.8.5; \
    docker-php-ext-enable swoole

RUN apk add --no-cache libc-dev \
    libsasl \
    libressl-dev

RUN docker-php-ext-install -j$(nproc) pcntl;

##############################
# INSTALL AND START COMPOSER #
##############################
RUN curl -sS https://getcomposer.org/installer -o composer-setup.php
RUN php composer-setup.php --install-dir=/usr/local/bin --filename=composer
RUN rm -rf composer-setup.php

#####################
# REMOVE BUILD DEPS #
#####################
RUN rm -rf /var/cache/apk/*

#####################
# REMOVE BUILD DEPS #
#####################
RUN mkdir /.npm
RUN mkdir /.cache
RUN chown -R 1000:1001 "/.npm"
RUN chown -R 1000:1001 "/.cache"

##########################
# START OCTANE WEBSERVER #
##########################
CMD ["php", "-i"]
@wglambert
Copy link

Looks like a bug? npm/cli#624 (comment)
npm/cli#950 (comment)
You mentioned running the container as node:node which this user said had worked around the issue, although relating more with using ssh keys npm/cli#950 (comment)

But otherwise I'm not sure if there's anything actionable that we could do to resolve this since it is the php image and not directly relevant to node, npm, or git

@wglambert wglambert added the question Usability question, not directly related to an error with the image label Jun 24, 2022
@Brotzka Brotzka closed this as completed Jun 26, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Usability question, not directly related to an error with the image
Projects
None yet
Development

No branches or pull requests

2 participants