Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix media uploads for Docker in rootless mode #50608

Closed
wants to merge 6 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions packages/env/lib/build-docker-compose-config.js
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand All @@ -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,
Expand Down Expand Up @@ -269,6 +275,8 @@ module.exports = function buildDockerComposeConfig( config ) {
'mysql-test': {},
'user-home': {},
'tests-user-home': {},
'wordpress-uploads': {},
'tests-wordpress-uploads': {},
},
};
};
3 changes: 3 additions & 0 deletions packages/env/lib/init-config.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 ) }`;
}
Expand Down
1 change: 1 addition & 0 deletions packages/env/lib/test/build-docker-compose-config.js
Original file line number Diff line number Diff line change
Expand Up @@ -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.
] );
Expand Down