如何为PHP和Node创建Docker映像? [英] How to create a Docker image for PHP and Node?
问题描述
我正在尝试为我的Angular创建一个其中包含PHP文件的Cocker容器。 Angular需要npm,所以我需要安装Node.js。我的项目不需要Apache,只需纯PHP即可。
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 project, just pure php should work fine.
我的理解是,我应该有一个
My understanding is I should have a
FROM node:latest
..install php here
RUN mkdir -p /usr/src/app
WORKDIR /usr/src/app
COPY package.json /usr/src/app
RUN npm install
COPY . /usr/src/app
我不确定如何安装PHP,有人可以将我指向右侧方向?非常感谢!
I am not sure how to install PHP in my case, Can anyone point me to the right direction? Thanks a lot!
推荐答案
我建议您采用其他方法。由于php比安装更长,因此请使用php映像并安装节点。
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
然后您有apache2提供了。 php文件。
And then you have apache2 provides .php files.
这篇关于如何为PHP和Node创建Docker映像?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!