I am trying to create a Cocker container for my Angular that has a PHP file in it. Angular requires npm so I need to have Node.js installed. I don\'t need Apache for my proj
I suggest you do it differently. Since php is longer than install, use the php image and install node.
FROM php:5.6-apache
RUN apt-get update && apt-get install -y node npm
#WORKDIR is /var/www/html
COPY . /var/www/html/
RUN npm install
And then you have apache2 provides .php files.
I think in this case the better way is using node docker image and PHP docker image together like bellow and not installing one of them by using apt-get install
FROM node:latest AS node
FROM php:7.4-fpm
COPY --from=node /usr/local/lib/node_modules /usr/local/lib/node_modules
COPY --from=node /usr/local/bin/node /usr/local/bin/node
RUN ln -s /usr/local/lib/node_modules/npm/bin/npm-cli.js /usr/local/bin/npm
RUN mkdir -p /usr/src/app
WORKDIR /usr/src/app
COPY package.json /usr/src/app
RUN npm install
COPY . /usr/src/app
in this way you don't need to install either node or PHP package every time that you change your code and rebuild from scratch is required in your Dockerfile