******EDIT
I've boiled this down to the following:
- I am moving my composer require commands to image build time rather than run time. I am not sure if this is ideal but it feels better.
- The composer commands need to update files in a mounted volume, which isn't done at run time. It should update files at /bitnami/drupal/modules/contrib
- This thread discusses my problem: Add a volume to Docker, but exclude a sub-folder
Relevant line from docker-compose
volumes:
- /docker/drupal9/template/site-files:/bitnami/drupal
I mount the /bitnami/drupal directory because, per the documentation on https://hub.docker.com/r/bitnami/drupal/, it is required for persistence.
Not sure how to best proceed but I'm going to troubleshoot "excluding sub-folders" so I can continue to mount the /bitnami/drupal volume while excluding the /bitnami/drupal/modules/contrib directory.
******END EDIT
I'm fairly new to Docker and confused on the best way to handle module installation and updates using composer on containerized Drupal 9 websites (at scale).
Background We manage ~50 websites. Some are unique enough that multi-site isn't appropriate for us. Most of them share the same tools. Regardless, we decided to containerize and each site is running from it's own codebase. We have persistent file storage and database in place.
- Platform: Drupal 9
- Base docker image: bitnami/drupal https://hub.docker.com/r/bitnami/drupal/ (with custom overrides)
- Hosting: AWS ECS Fargate (serverless) and a mixture of S3/EFS/RDS
What we're doing now: The custom Dockerfile is FROM bitnami/drupal but has a few overrides, including a custom ENTRYPOINT file it runs every time the container starts. The ENTRYPOINT file contains a list of "composer require" commands which install necessary contrib modules.
This works OK, as it's easy to push a new image with updates and reboot every container to make sure they're all applied.
The problem: Any time we reboot the container or want to add a new module to this list, the ENTRYPOINT file runs through all "composer require" statements. This causes strain on our internal dev machine and takes a fair bit of time.
We've tried removing the composer statements from the ENTRYPOINT file, but then we aren't sure how to update all websites at once.
What we're thinking: Do we need to maintain multiple images? One with all composer require statements used for standing up new sites, and one with no composer require statements, used for production hosting, container rebooting, etc... Then a third for running composer update at scale?
Is there an easy drush solution I'm missing here? Some workflow for pulling in a controlled composer.json? Are we overthinking this?
I was hoping to avoid any sort of ecs-exec looping.
To summarize, I cannot wrap my head around best implementation given the following criteria:
- Push button updates (of core and contrib modules) at scale
- Push button addition of new contrib module at scale
- Not having to reinstall every module every time
- Supports creating new websites with all required modules and composer.json
Thank you!