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:
docker-compose.yml:
server:
image: richarvey/nginx-fpm (or any other sensible default)
container-name: "Civi Webserver"
volumes-from: app
db:
image: mysql
container-name: "Civi DB"
volumes-from: app
app:
build: app
container-name: "Civi App"
app/Dockerfile
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.