From dc8ed0caad7c8cf9891e3ed2ba359c4c4ca2e34d Mon Sep 17 00:00:00 2001 From: Don Richards <2738244+DonRichards@users.noreply.github.com> Date: Wed, 21 Aug 2024 13:54:22 -0400 Subject: [PATCH] Run composer as nginx user to avoid permissions conflict. (#400) * Run composer as nginx user to avoid permissions conflict. * Update Makefile * add change ownership prior to starter-init * Update Makefile * Removed run as nginx since this these 2 are dropping into root's home dir * Update Makefile --- Makefile | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Makefile b/Makefile index 48870a1e8..361e91f4b 100644 --- a/Makefile +++ b/Makefile @@ -154,9 +154,9 @@ starter: QUOTED_CURDIR = "$(CURDIR)" starter: generate-secrets $(MAKE) starter-init ENVIRONMENT=starter if [ -z "$$(ls -A $(QUOTED_CURDIR)/codebase)" ]; then \ - docker container run --rm -v $(CURDIR)/codebase:/home/root $(REPOSITORY)/nginx:$(TAG) with-contenv bash -lc 'composer create-project $(CODEBASE_PACKAGE) /tmp/codebase; mv /tmp/codebase/* /home/root;'; \ + docker container run --rm -v $(CURDIR)/codebase:/home/root $(REPOSITORY)/nginx:$(TAG) with-contenv bash -lc 'composer create-project $(CODEBASE_PACKAGE) /tmp/codebase && mv /tmp/codebase/* /home/root'; \ else \ - docker container run --rm -v $(CURDIR)/codebase:/home/root $(REPOSITORY)/nginx:$(TAG) with-contenv bash -lc 'cd /home/root; composer install'; \ + docker container run --rm -v $(CURDIR)/codebase:/home/root $(REPOSITORY)/nginx:$(TAG) with-contenv bash -lc 'cd /home/root && composer install'; \ fi $(MAKE) set-files-owner SRC=$(CURDIR)/codebase ENVIRONMENT=starter $(MAKE) compose-up @@ -173,14 +173,14 @@ starter_dev: generate-secrets fi $(MAKE) set-files-owner SRC=$(CURDIR)/codebase ENVIRONMENT=starter_dev $(MAKE) compose-up - docker compose exec -T drupal with-contenv bash -lc 'chown -R nginx:nginx /var/www/drupal/ ; su nginx -s /bin/bash -c "composer install"' + docker compose exec -T -u nginx drupal sh -c 'composer install' $(MAKE) starter-finalize ENVIRONMENT=starter_dev .PHONY: production production: init $(MAKE) compose-up - docker compose exec -T drupal with-contenv bash -lc 'composer install; chown -R nginx:nginx .' + docker compose exec -T -u nginx drupal sh -c 'composer install && chown -R nginx:nginx .' $(MAKE) starter-finalize ENVIRONMENT=starter