diff --git a/test-and-deploy.yml b/test-and-deploy.yml
index ec5edb94e2f2fa21891299bab2a6b8fd6ae248ca..1b3379fb824f120b3fa4df7cd1bd011856941095 100644
--- a/test-and-deploy.yml
+++ b/test-and-deploy.yml
@@ -550,6 +550,10 @@ Debug:
   variables:
     GIT_STRATEGY: fetch
   script:
+    - docker compose exec -u root php chown -R www-data:www-data .
+    - docker compose exec -u root php chmod -R ug-w .
+    - docker compose exec -u root php bash -c 'chmod -R ug+w web/sites/*/files'
+    - docker compose exec -u root php bash -c 'chmod -R ug+w web/sites/*/private'
     - ${INITIAL_SETUP_COMMAND}
     - drush cr
   rules: