I have the next docker-compose.yml file
version: '2'
services:
  # The Application
  app:
    build:
      context: ./
      dockerfile: app.dockerfile
    working_dir: /var/www/html
    volumes:
      - ./giftmeabetterplanet:/var/www/html
    environment:
      - "DB_PORT=3306"
      - "DB_HOST=database"
  # The Web Server
  web:
    build:
      context: ./
      dockerfile: web.dockerfile
    working_dir: /var/www/html
    links:
      - database:mysql
    volumes_from:
      - app
    ports:
      - 81:80
    environment:
      - "WEB_DOCUMENT_ROOT=/var/www/html/public"
  # The Database
  database:
    image: mysql:5.6
    volumes:
      - dbdata:/var/lib/mysql
    environment:
      - "MYSQL_DATABASE=homestead"
      - "MYSQL_USER=homestead"
      - "MYSQL_PASSWORD=secret"
      - "MYSQL_ROOT_PASSWORD=secret"
    ports:
        - "3306"
volumes:
  dbdata:
I need to make NPM (node package manager) accessible somehow to build my JS and CSS files in 'web' container.
app.dockerfile
FROM php:7.0.4
RUN apt-get update && apt-get install -y libmcrypt-dev \
    mysql-client libmagickwand-dev --no-install-recommends \
    && pecl install imagick \
    && docker-php-ext-enable imagick \
    && docker-php-ext-install mcrypt pdo_mysql
web.dockerfile
FROM webdevops/php-apache-dev:ubuntu-16.04
I've tried the next way by extending web.dockerfile
FROM orlandohohmeier/local-npm
FROM webdevops/php-apache-dev:ubuntu-16.04
But npm is not accessible from the command line in 'web' container. Maybe i don't understand some concepts but i just want to compile my stiles, javascript files and copy fonts from node-modules.
Best regards. Ivan
For PHP7.2 this is what I have in my php.dockerfile
RUN curl -sL https://deb.nodesource.com/setup_8.x | bash - 
RUN apt-get install -y nodejs
Add to the docker-compose file
npm:  
  image: node:14
  working_dir: /var/www/my_shiny_project
  entrypoint: ["npm"]
  volumes: 
    - "./www/:/var/www/my_shiny_project"
Usage:
docker-compose run --rm npm install
Don't forget to check the paths in both working_dir and volumes
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With