dsavell / docker-grav

Docker Container for GRAV CMS
MIT License
40 stars 18 forks source link

Container customisation parameters #27

Closed hughbris closed 3 years ago

hughbris commented 3 years ago

I've been wanting for a while to be able to pass parameters to docker run or docker-compose that allow me to add PHP libraries (like sqlite) or Grav plugins/themes. Mostly the former.

I guess this is more a docker image modification thing than something that can be added at runtime (container instantiation), but my understanding is limited and my attempts to research it have only added to my confusion. I'm yet to find good online Docker resources that address (what I assume) are common use cases like this.

Is there a way you know of? Otherwise I'm left with running my customisations in the container, or creating private image builds for each configuration I need (again, mostly a problem for PHP library packages).

mabushey commented 3 years ago

I use the git-sync plugin. I modified the Dockerfile to install git, and modified the init script to do a git clone using ENV vars for the repo/user/pass. This way the same container image can be called multiple times to pull up different sites in each container. git-sync commits everything in user, which includes user/plugins and user/themes.

PHP libraries would need to be added to the Dockerfile.

dsavell commented 3 years ago

Hello, will give some brief answers.

  1. PHP libs will require a custom image built from the Dockerfiles as it changes the operating system layer.
  2. Plugins and themes or any user specific data can be retained when pulling and rerunning a new image by using the following mount input: -v /data/containers/grav/user:/var/www/grav/user
hughbris commented 3 years ago

Thanks @dsavell and apologies for not replying much sooner when I realised my request was misguided. This is indeed necessarily part of the build process and not an option at runtime. New image tags would be the only way to provide optional PHP libraries. These would be limited to common combinations and are not a proper parameterised solution.