FROM wordpress
#make sure necessary tools for publishing are installed
RUN curl -sL https://deb.nodesource.com/setup_4.x | bash - && \
apt-get install -y nodejs git && \
npm install -g npm gulp bower
ADD . /var/www/html/wp-content/themes/new-theme
RUN cd /var/www/html/wp-content/themes/new-theme \
&& npm install \
&& npm run build \
&& rm -rf node_modules \
&& rm -rf bower_components \
&& find ./* -type f -printf "%h%f\n" | sort \
&& cd /
VOLUME ["/var/www/html/wp-content/themes/new-theme"]
ENTRYPOINT ["/entrypoint.sh"]
CMD ["apache2-foreground"]
When I build it, the second RUN command produces several files that get dropped into the /var/www/html/wp-content/themes/ca-ticket.com/dist folder, and when I view the build log I can see clearly that the files are getting created (that is why the find ./* -type f -printf "%h%f\n" | sort is there.
You have VOLUME ["/var/www/html/wp-content/themes/new-theme"]. That means a volume will be mounted in that location when you run the image. Volumes are just bind mounts. When something is mounted to a directory, it hides any contents of that directory.
But the files that get added in the ADD stage are all present at the same path when I do a docker exec -t -i <containername> bash and ls /var/www/html/wp-content/themes/new-theme - the only missing files are those that get generated during the subsequent RUN.
I just tried re-running with the volume commented out with the exact same outcome. I have the volume there because when I am doing dev work I mount the volume to a local path for me to work on the theme, but when publishing the image I run without the volume at all.
The wordpress container will do a bunch of black magic with /var/www/html. Due to wordpress’s approach in keeping state on the filesystem, the wordpress’s entrypoint.sh script will populate it with a vanilla wordpress install at runtime.
Any changes to that location at build time are masked by the /var/www/html volume.
What you might have to do is ADD your files to another location, and then get the wordpress entrypoint.sh script to set up a symlink at runtime after doing the initial wordpress download/install.
I’ve currently just folded their Dockerfile into my own and removed the extra VOLUME - if this works I may have to just fork their dockerfile and do exactly what you suggested.
Thank you so much for the help; can be tough working in a vacuum!