diff --git a/packages/env/lib/build-docker-compose-config.js b/packages/env/lib/build-docker-compose-config.js index 5336f8690cca85..01bce2bafbd83b 100644 --- a/packages/env/lib/build-docker-compose-config.js +++ b/packages/env/lib/build-docker-compose-config.js @@ -54,6 +54,11 @@ function getMounts( ? `user-home:/home/${ hostUsername }` : `tests-user-home:/home/${ hostUsername }`; + const wordpressUploadsMount = + wordpressDefault === 'wordpress' + ? `wordpress-uploads:/var/www/html/wp-content/uploads` + : `tests-wordpress-uploads:/var/www/html/wp-content/uploads`; + const corePHPUnitMount = `${ path.join( workDirectoryPath, wordpressDefault === 'wordpress' @@ -72,6 +77,7 @@ function getMounts( coreMount, // Must be first because of some operations later that expect it to be! corePHPUnitMount, userHomeMount, + wordpressUploadsMount, ...directoryMounts, ...pluginMounts, ...themeMounts, @@ -269,6 +275,8 @@ module.exports = function buildDockerComposeConfig( config ) { 'mysql-test': {}, 'user-home': {}, 'tests-user-home': {}, + 'wordpress-uploads': {}, + 'tests-wordpress-uploads': {}, }, }; }; diff --git a/packages/env/lib/init-config.js b/packages/env/lib/init-config.js index 4a573c97aae7e9..3db99aba5748be 100644 --- a/packages/env/lib/init-config.js +++ b/packages/env/lib/init-config.js @@ -136,6 +136,9 @@ ARG HOST_GID RUN groupadd -g $HOST_GID $HOST_USERNAME || true RUN useradd -m -u $HOST_UID -g $HOST_GID $HOST_USERNAME || true +# Make media uploads writeable by the host user. +RUN install -d -o $HOST_UID -g $HOST_GID /var/www/html/wp-content/uploads + # Install any dependencies we need in the container. ${ installDependencies( 'wordpress', env, config ) }`; } diff --git a/packages/env/lib/test/build-docker-compose-config.js b/packages/env/lib/test/build-docker-compose-config.js index 95cf6419d5db4d..f0b67b18cfdb1e 100644 --- a/packages/env/lib/test/build-docker-compose-config.js +++ b/packages/env/lib/test/build-docker-compose-config.js @@ -46,6 +46,7 @@ describe( 'buildDockerComposeConfig', () => { 'wordpress:/var/www/html', // WordPress root. '/path/WordPress-PHPUnit/tests/phpunit:/wordpress-phpunit', // WordPress test library, 'user-home:/home/test', + 'wordpress-uploads:/var/www/html/wp-content/uploads', '/path/to/wp-plugins:/var/www/html/wp-content/plugins', // Mapped plugins root. '/path/to/local/plugin:/var/www/html/wp-content/plugins/test-name', // Mapped plugin. ] );