I'm trying to create a reliable Docker image for CiviCRM since there are none in the Docker hub which are bundled with READMEs or readable Dockerfile build code. The only image which is well-documented doesn't comply with standard Docker conventions. Here's the project: https://github.com/djcf/civibuild-docker
So, I wrote this Dockerfile which installs a standard installation using the CiviCRM buildkit. The only problem is it doesn't work. I had it working a week or so ago, but now nothing I do to build it is successful. (I even tried re-running the buildkit commit current at the time I first tried to install Civi in Docker -- https://raw.githubusercontent.com/civicrm/civicrm-buildkit/666d74d1e862957986e3b91c3206e3717d7058a1/bin/civi-download-tools -- no luck.
The Dockerfile is quite simple.
FROM colstrom/fish:ubuntu
# (this adds the Friendly Interactive Shell to Ubuntu 14.04
ENV CIVITYPE drupal-clean
ENV CMS_ROOT /buildkit/build
ENV SITE_NAME "Civi"
ENV SITE_ID "civi"
ENV TMPDIR /buildkit/tmp
RUN apt-get update; apt-get install -y curl links ssmtp
RUN curl -Ls https://civicrm.org/get-buildkit.sh | bash -s -- --full --dir /buildkit
COPY dbconf.sh /buildkit
COPY postinstall.sh /buildkit
# This is the problem part --
# but it makes three different errors depending on what environment its run.
RUN /buildkit/bin/civibuild create civicrm --type drupal-clean --url http://localhost:80 --admin-pass 123
RUN apt-get install -y runit
RUN /buildkit/postinstall.sh; apt-get clean; rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
VOLUME /buildkit/build
VOLUME /var/lib/mysql
EXPOSE 80
ENTRYPOINT ["/usr/sbin/docker-entrypoint.sh"]
The dbconf.sh pre-install script makes sure MySQL is running, and copies across some configuration needed for the script. In particular it makes sure amp can talk to MySQL, that amp has the correct settings to talk to MySQL, and that bower will accept being run by the root user.
Now here is the curious thing.
When I run the buildscript (docker build -t civibuild .) the build fails at the beginning of the buildkit build command: Step 15 : RUN /buildkit/dbconf.sh ; /buildkit/bin/civibuild create civicrm --type drupal-clean --url http://localhost:80 --admin-pass 123
---> Running in 3f9999dbdb12
* Starting MySQL database server mysqld
...done.
* Checking for tables which need an upgrade, are corrupt or were
not closed cleanly.
Finished running pr-configuration, will now install CiviCRM using buildkit buildscript.
ln: failed to create symbolic link 'bower': File exists
The command '/bin/sh -c /buildkit/dbconf.sh ; /buildkit /bin/civibuild create civicrm --type drupal-clean --url http://localhost:80 --admin-pass 123' returned a non-zero code: 1
So I tried to run EXACT THE SAME STEPS manually in a vanilla Ubuntu 14.04 Docker image (docker run --it ubuntu:14.04 /bin/bash). This time the Civi build gets about half-way thru then errors:
CiviCRM was isntalled successfully [ok]
/buildkit/app/config/drupal-clean/install.sh: line 42: 17650
Segmentation fault (core dumped) drush -y dis overlay
I then tried to run the EXACT SAME STEPS manually in a Vagrant image . This time the script completes successfully.
The solution was eventually traced to an invalid docker build cache. In a previous run, bower had failed to install and the cache had kept a bad symlink.
Solution: run with docker build --no-cache.