I am trying to use Docker in order to run my php - gulp website. Here is the tree of what I've created:
├── 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
The app folder contains all my php files:
app
├── folder1
│ └── index.php
├── folder2
│ └── index.php
├── folder3
│ └── index.php
├── footer.php
├── header.php
└── index.php
My gulpfile.js contains all the tasks to compile and build my website. It is working well. The command I use to run is gulp build-production && gulp serve:dist
due to the name of the tasks I've created.
So in my Dockerfile, I added the following lines in order to make my app running in my 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 [email protected]
RUN npm i gulp-cli
VOLUME ["/app"]
CMD ["gulp build-production && gulp serve:dist"]
When I am running docker build -t myapp .
all the steps are working well without returning any error.
But then when I run docker run myapp
I got the following error:
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
I am very confused so if anyone has a solution it would be awesome.
First, you should use node image instead of ubuntu, because with this you do not need to reinstall it later.
I think your main problem is that you should create app directory first and copy all your website content.
Then you can also remove VOLUME
this is useless in your case.
Something you can try:
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