php - DOCKER:运行 gulp-php 网站时出错
问题描述
我正在尝试使用 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
推荐阅读
- extjs - .war 中的 EXTJS 6 应用程序部署在代理后面的码头上
- apache-spark - 如何在写入雪花时使用 Spark/PySpark 将 timestamp_ntz 类型转换为 CST 格式
- python - 在 mongodb 中查询嵌套搜索,没有来自最终用户的点符号
- react-native - 在一段时间后锁定 React Native 应用程序
- docker - 如何使用来自 Docker 主机的主机名连接到 Docker 容器?
- indexing - 为什么Top N查询场景Oracle不使用索引?
- java - 使用其他方法的变量
- c# - 在 Ubuntu 中从 ttyUSB 端口创建 COM 端口
- regex - 用于排序的正则表达式
- docker - 如何取消 Nginx 上传限制?