亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

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 [email protected] 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 關注
  • 161 瀏覽

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號