Would you please advise on how to install npm and composer dependencies in my webroot via the
Dockerfile on a AWS Elasticbeanstalk Multi-Container Docker app?
I've been building my files from within the docker container via the Dockerfile with code like this:
// Dockerfile ... # npm WORKDIR /var/www/tmp_html RUN mkdir -p npm WORKDIR /var/www/tmp_html/npm COPY php-app/package.json package.json RUN npm update && npm install # composer ... // similar to above # Switch working directory back to webroot WORKDIR /var/www/html
After deployment, when I ssh into the instance's
php:fpm container, i can see the following structure:
root@3f8bf1xc2a78:/var/www# ls html tmp_html
The built files are in /tmp_html and i'm trying to move them into /html. via my Dockerfile like this:
ONBUILD RUN mv -v ../tmp_html/composer/protected/vendor/* protected/vendor \ && rm -rf ../tmp_html/composer/protected \ && mv -v ../tmp_html/composer/* . \ && mv -v ../tmp_html/npm/* . \ && rm -rf ../tmp_html
Problem is, the ONBUILD step is not working. On Docker Inspect the php:fpm container, i noticed this: "OnBuild": null. It seems like the onbuild didn't even run. The files in the the
/tmp_html folders remain the same.
Furthermore, if i RUN the commands plainly without the ONBUILD command, on docker push to the docker image repository, the target location cannot be detected and refuses to let me push so i can't even deploy. The error is:
mv: target 'protected/vendor' is not a directory
I guess this is because elasticbeanstalk hasn't copied the bundle in, so at this point the html folder isn't even available.