What madness is this? Sorry for the daft title. Let me explain.

I'm trying to create a docker image for CiviCRM which separates out the web server, database server, and program data itself. In theory, I believe such a container could be very useful to the community. Yes, we have several docker images which do this. I even built one myself using the CiviCRM buildkit. However, none of them really follow the docker principles:

  • We can't choose our own web servers in separate containers (i.e. they are not composable)
  • We can't use standard docker tools for e.g. managing the SQL database (i.e. they do not conform to established principles).
  • Some of them do not even install programatically!

So the plan here is actually quite simple but my lack of knowledge of the CiviCRM install process is hampering me a bit. First, we define a docker-compose file which sets up sensible defaults for the SQL serverand web server containers, allowing the user to swap out other ones if they so desire. It also defines a data container which grabs CiviCRM program code in the build stage, then installs the database in the run stage, then quits.

Like this:


    image: richarvey/nginx-fpm (or any other sensible default)
    container-name: "Civi Webserver"
    volumes-from: app
    image: mysql
    container-name: "Civi DB"
    volumes-from: app
    build: app
    container-name: "Civi App"


from debian:jessie
# 1: download the build tool
RUN curl -Ls https://civicrm.org/get-buildkit.sh | bash -s -- --full --dir /buildkit
# OR install drush/composer/some other equivalent tool

# 2: download the CiviCRM program code
RUN /buildkit/bin/civibuild create dmaster --no-init-db /var/www/html
# OR some other equivalent command using drush etc.

# 3: prepare to initialise the db
COPY initialize-civicrm-db.sh

# 4: When the container is run it will initialise the database, then quit.
CMD intialize-civicrm-db.sh

VOLUME /var/www/html

To summarise: I'm looking for a way to install CiviCRM in such a way that the build tool does not also try to install the database. Then I also need a way to install the database without installing the program code.


From the excellent interactive documentation here -- https://buildkit.civicrm.org/#/tutorials (which is almost impossible to find unless you know where to look):

## Download application (with civibuild)
civibuild download "mytestbuild" \
  --civi-ver "master" \
  --type "drupal-clean"

There are a number of interesting gotchas. For example, civibuild download does not download dependencies for civi, it only downloads civi and the CMS. So you may wish to run composer install and npm install between these two stages. Otherwise, both will be run automatically next.

Then install the DB and the rest of the application:

## Install application (with civibuild)
civibuild install "mytestbuild" \
  --url "http://localhost:8000" \
  --admin-pass "n0ts3cr3t"
| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.