php - DOCKER:运行gulp-php网站时出错

标签 php docker gulp

我正在尝试使用Docker来运行我的php-gulp网站。
这是我创建的树:

├── app <--------------------contains the php files
├── blog-theme
├── bower_components
├── changelog-YYYY-MM-DD.md
├── dist
├── Dockerfile <-----------------------DOCKERFILE
├── get-git-log.sh
├── git-log.txt
├── gulpfile.js <------------------all my gulp tasks are here 
├── node_modules
├── package.json
├── package-lock.json
├── README.md
├── Releases
├── ressources
├── website_test.sh
└── yarn.lock
app文件夹包含我所有的php文件:
app
├── folder1
│   └── index.php
├── folder2
│   └── index.php
├── folder3
│   └── index.php
├── footer.php
├── header.php
└── index.php
我的gulpfile.js包含所有编译和构建我的网站的任务。运行良好。由于创建的任务名称,我用来运行的命令是gulp build-production && gulp serve:dist
因此,在我的Dockerfile中,添加了以下几行以使我的应用程序在我的Docker中运行:
FROM ubuntu:16.04

WORKDIR /app

RUN apt-get update
RUN apt-get install -y build-essential
RUN apt-get update && apt-get install -y curl
RUN curl -sL https://deb.nodesource.com/setup_8.x | bash -
RUN apt-get update && apt-get install -y nodejs
RUN npm install -g npm
RUN npm install -g n
RUN n 13.6.0
RUN npm i gulp@4.0.2
RUN npm i gulp-cli

VOLUME ["/app"]
CMD ["gulp build-production && gulp serve:dist"]
当我运行docker build -t myapp .时,所有步骤都运行良好,并且没有返回任何错误。
但是当我运行docker run myapp时,出现以下错误:
docker: Error response from daemon: OCI runtime create failed: container_linux.go:349: starting container process caused "exec: \"gulp build-production && gulp serve:dist\": executable file not found in $PATH": unknown.
ERRO[0001] error waiting for container: context canceled 
我很困惑,所以如果有人有解决方案,那就太好了。

最佳答案

首先,您应该使用节点镜像而不是ubuntu,因为有了它,您以后不必重新安装它。
我认为您的主要问题是,您应该首先创建应用程序目录并复制所有网站内容。
然后,您也可以删除VOLUME,这对您来说是没有用的。
您可以尝试以下操作:

FROM node:14

RUN mkdir /app
WORKDIR /app

COPY . /app
RUN apt update
RUN apt install -y php
RUN npm install -g n
RUN n 13.6.0
RUN npm i -g gulp-cli
RUN npm install

ENV PATH=$PATH:/app/node_modules/.bin
ENTRYPOINT [] # to bypass default node
CMD gulp serve:dist

关于php - DOCKER:运行gulp-php网站时出错,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/62764269/

相关文章:

windows - 无法访问 Windows 节点上的 Kubernetes 服务

linux - "RUN ./configure"=> 在 Docker 中找不到,"RUN cd srcdir && chmod +x ./configure"成功后

javascript - Gulp JavaScript 文件过滤,无需其父文件夹

css - 尝试在 calc() 中使用 theme() 时出现解析错误

javascript - .htaccess文件不加载js和css

php - 带有或条件的Mysql案例

php - MySQL 查询 PHP 中的字符串问题

php - 登录功能似乎无法正常运行

python - 在 Docker 中安装和使用 pip 和 virtualenv

javascript - Gulp 和 Bower 集成