diff --git a/README.md b/README.md index ceea278..95b0904 100644 --- a/README.md +++ b/README.md @@ -81,6 +81,20 @@ You can then: See [publish/README.md](publish/README.md) for instructions on how to build CiviCRM containers that use different versions of PHP. +## Custom builds + +This repository comes with a `docker-compose-build.yml` that can be used for custom builds. One option is to rename it to `docker-compose.yml` and follow the commands above. Alternatively, you can references it in docker-compose commands with the --file argument, e.g.: + +``` +docker-compose --file /path/to/docker-compose-build.yml up -d +``` + +Custom builds are useful if you want to pass particular arguments to the build. For example, you can define the UID and GID of the buildkit user (see below). + +### UID and GID conflicts + +Bind mounts are fussy when it comes to user ids and group ids. If the user on your host machine has a different UID and GID to the buildkit user in the container (which is 1000 by default), you can create a custom build that passes BUILDKIT_UID and BUILDKIT_GID as arguments. + ## Getting help Feel free to ask any questions you have on the [sysadmin](https://chat.civicrm.org/civicrm/channels/sysadmin) chatroom (mentioning @michaelmcandrew if you feel like it), or file an issue in the [github issue queue](https://github.com/michaelmcandrew/civicrm-buildkit-docker/issues). diff --git a/civicrm/Dockerfile b/civicrm/Dockerfile index 150c34e..2aeaf86 100644 --- a/civicrm/Dockerfile +++ b/civicrm/Dockerfile @@ -57,7 +57,13 @@ RUN pecl install imagick \ RUN a2enmod rewrite -RUN useradd --home-dir /buildkit --create-home buildkit +ARG BUILDKIT_UID=1000 + +ARG BUILDKIT_GID=$BUILDKIT_UID + +RUN addgroup --gid=$BUILDKIT_GID buildkit + +RUN useradd --home-dir /buildkit --create-home --uid $BUILDKIT_UID --gid $BUILDKIT_GID buildkit COPY sudo /etc/sudoers.d/buildkit diff --git a/docker-compose-build.yml b/docker-compose-build.yml new file mode 100644 index 0000000..aa96550 --- /dev/null +++ b/docker-compose-build.yml @@ -0,0 +1,65 @@ +version: '3.4' + +services: + + civicrm: + build: + context: civicrm + args: + BUILDKIT_UID: 1001 + # BUILDKIT_GID: 1001 # By default, this will be the same as the UID + hostname: civicrm + environment: + TERM: xterm-color + APACHE_RUN_USER: buildkit + links: + - mysql + ports: + - "8080:8080" + volumes: + - buildkit:/buildkit + - ./build:/buildkit/build + - ./extra:/extra + - amp:/buildkit/.amp + - bower-cache:/buildkit/.cache/bower + - composer-cache:/buildkit/.composer + - drush-cache:/buildkit/.drush + - npm-cache:/buildkit/.npm + - git-cache:/buildkit/app/tmp/git-cache + restart: always + + mysql: + image: mysql:5.7 + environment: + MYSQL_ROOT_PASSWORD: buildkit + volumes: + - mysql:/var/lib/mysql + restart: always + + phpmyadmin: + image: phpmyadmin/phpmyadmin + ports: + - "8081:80" + links: + - mysql + environment: + PMA_HOST: mysql + PMA_USER: root + PMA_PASSWORD: buildkit + restart: always + + maildev: + image: djfarrelly/maildev + ports: + - "8082:80" + restart: always + +volumes: + amp: + buildkit: + bower-cache: + composer-cache: + drush-cache: + git-cache: + npm-cache: + mysql: diff --git a/publish/civicrm/php5.6/Dockerfile b/publish/civicrm/php5.6/Dockerfile index 33fa87c..4392955 100644 --- a/publish/civicrm/php5.6/Dockerfile +++ b/publish/civicrm/php5.6/Dockerfile @@ -57,7 +57,13 @@ RUN pecl install imagick \ RUN a2enmod rewrite -RUN useradd --home-dir /buildkit --create-home buildkit +ARG BUILDKIT_UID=1000 + +ARG BUILDKIT_GID=$BUILDKIT_UID + +RUN addgroup --gid=$BUILDKIT_GID buildkit + +RUN useradd --home-dir /buildkit --create-home --uid $BUILDKIT_UID --gid $BUILDKIT_GID buildkit COPY sudo /etc/sudoers.d/buildkit diff --git a/publish/civicrm/php7.0/Dockerfile b/publish/civicrm/php7.0/Dockerfile index 150c34e..2aeaf86 100644 --- a/publish/civicrm/php7.0/Dockerfile +++ b/publish/civicrm/php7.0/Dockerfile @@ -57,7 +57,13 @@ RUN pecl install imagick \ RUN a2enmod rewrite -RUN useradd --home-dir /buildkit --create-home buildkit +ARG BUILDKIT_UID=1000 + +ARG BUILDKIT_GID=$BUILDKIT_UID + +RUN addgroup --gid=$BUILDKIT_GID buildkit + +RUN useradd --home-dir /buildkit --create-home --uid $BUILDKIT_UID --gid $BUILDKIT_GID buildkit COPY sudo /etc/sudoers.d/buildkit diff --git a/publish/civicrm/php7.1/Dockerfile b/publish/civicrm/php7.1/Dockerfile index 6686a1a..9ecdfac 100644 --- a/publish/civicrm/php7.1/Dockerfile +++ b/publish/civicrm/php7.1/Dockerfile @@ -57,7 +57,13 @@ RUN pecl install imagick \ RUN a2enmod rewrite -RUN useradd --home-dir /buildkit --create-home buildkit +ARG BUILDKIT_UID=1000 + +ARG BUILDKIT_GID=$BUILDKIT_UID + +RUN addgroup --gid=$BUILDKIT_GID buildkit + +RUN useradd --home-dir /buildkit --create-home --uid $BUILDKIT_UID --gid $BUILDKIT_GID buildkit COPY sudo /etc/sudoers.d/buildkit diff --git a/publish/civicrm/php7.2/Dockerfile b/publish/civicrm/php7.2/Dockerfile index dedd175..49b4760 100644 --- a/publish/civicrm/php7.2/Dockerfile +++ b/publish/civicrm/php7.2/Dockerfile @@ -57,7 +57,13 @@ RUN pecl install imagick \ RUN a2enmod rewrite -RUN useradd --home-dir /buildkit --create-home buildkit +ARG BUILDKIT_UID=1000 + +ARG BUILDKIT_GID=$BUILDKIT_UID + +RUN addgroup --gid=$BUILDKIT_GID buildkit + +RUN useradd --home-dir /buildkit --create-home --uid $BUILDKIT_UID --gid $BUILDKIT_GID buildkit COPY sudo /etc/sudoers.d/buildkit diff --git a/publish/templates/civicrm/Dockerfile.twig b/publish/templates/civicrm/Dockerfile.twig index a5d39f9..c79da5c 100644 --- a/publish/templates/civicrm/Dockerfile.twig +++ b/publish/templates/civicrm/Dockerfile.twig @@ -61,7 +61,13 @@ RUN pecl install imagick \ RUN a2enmod rewrite -RUN useradd --home-dir /buildkit --create-home buildkit +ARG BUILDKIT_UID=1000 + +ARG BUILDKIT_GID=$BUILDKIT_UID + +RUN addgroup --gid=$BUILDKIT_GID buildkit + +RUN useradd --home-dir /buildkit --create-home --uid $BUILDKIT_UID --gid $BUILDKIT_GID buildkit COPY sudo /etc/sudoers.d/buildkit