Skip to content

Commit

Permalink
pass UID and GID as arguments to civicrm Dockerfile
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelmcandrew committed May 18, 2018
1 parent edf58df commit 43a86dc
Show file tree
Hide file tree
Showing 8 changed files with 121 additions and 6 deletions.
14 changes: 14 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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).
Expand Down
8 changes: 7 additions & 1 deletion civicrm/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
65 changes: 65 additions & 0 deletions docker-compose-build.yml
Original file line number Diff line number Diff line change
@@ -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:
8 changes: 7 additions & 1 deletion publish/civicrm/php5.6/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
8 changes: 7 additions & 1 deletion publish/civicrm/php7.0/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
8 changes: 7 additions & 1 deletion publish/civicrm/php7.1/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
8 changes: 7 additions & 1 deletion publish/civicrm/php7.2/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
8 changes: 7 additions & 1 deletion publish/templates/civicrm/Dockerfile.twig
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down

0 comments on commit 43a86dc

Please sign in to comment.