为了账号安全,请及时绑定邮箱和手机立即绑定

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

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

PHP
慕神8447489 2023-07-15 16:46:03
我正在尝试使用 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.lockapp 文件夹包含我所有的 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.04WORKDIR /appRUN apt-get updateRUN apt-get install -y build-essentialRUN apt-get update && apt-get install -y curlRUN curl -sL https://deb.nodesource.com/setup_8.x | bash -RUN apt-get update && apt-get install -y nodejsRUN npm install -g npmRUN npm install -g nRUN n 13.6.0RUN npm i gulp@4.0.2RUN npm i gulp-cliVOLUME ["/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 我很困惑,所以如果有人有解决方案那就太棒了。
查看完整描述

2 回答

?
慕盖茨4494581

TA贡献1850条经验 获得超11个赞

首先,你应该使用node镜像而不是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


查看完整回答
反对 回复 2023-07-15
?
慕少森

TA贡献2019条经验 获得超9个赞

/app/node_modules/.bin/不在你的$PATH. 添加它ENV PATH=$PATH:/app/node_modules/.bin或在 gulp 前面添加路径CMD ["/app/node_modules/.bin/gulp build-production && /app/node_modules/.bin/gulp serve:dist"]



查看完整回答
反对 回复 2023-07-15
  • 2 回答
  • 0 关注
  • 105 浏览

添加回答

举报

0/150
提交
取消
意见反馈 帮助中心 APP下载
官方微信