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

Adding custom theme and plugins #115

Closed
bkcummins opened this issue Jan 7, 2016 · 13 comments
Closed

Adding custom theme and plugins #115

bkcummins opened this issue Jan 7, 2016 · 13 comments

Comments

@bkcummins
Copy link

I struggled to build an image which would copy custom themes and plugins to /var/www/html/wp-content yet still retain www-data ownership for these files. I think this was due to the VOLUME in your image.

I was successful with the following.

FROM wordpress
COPY ["wordpress","/usr/src/wordpress"]
RUN chown -R www-data:www-data /usr/src/wordpress/*

Is this the best way to complete this or should I be approaching it differently?
bkc

@lazyfrosch
Copy link

You should do this in the entrypoint. That's where the image is actually installing data to /var/www/html.

@md5
Copy link
Contributor

md5 commented Jan 7, 2016

@lazyfrosch The entrypoint copies files from /usr/src/wordpress to /var/www/html, so what @bkcummins is doing is the right way to do it.

@md5
Copy link
Contributor

md5 commented Jan 7, 2016

That being said, I would probably COPY just the plugins and themes into the right directories in /usr/src/wordpress/wp-content instead of overwriting the entire /usr/src/wordpress directory.

@bkcummins
Copy link
Author

great...thx for the feedback guys.

@lazyfrosch
Copy link

@md5 yes, but a volume should be touched in the entrypoint, and not in Dockerfile. Or it might now work when mounting in that volume...

@md5
Copy link
Contributor

md5 commented Jan 13, 2016

@lazyfrosch The entrypoint already copies from /usr/src/wordpress into the volume on startup if it doesn't find an existing WordPress installation in a mounted volume. See here:

tar cf - --one-file-system -C /usr/src/wordpress . | tar xf -

@tianon
Copy link
Member

tianon commented Aug 22, 2016

What's been said is definitely correct IMO -- if you want to create a "production" version of the wordpress image with your plugins/themes pre-installed, them placing them in the appropriate place within /usr/src/wordpress is correct.

I'd note also that bind-mounting into /var/www/html directly for development (as I've described over in #64 (comment)) is also a pattern we've found to be reasonably effective. 👍

@tianon tianon closed this as completed Aug 22, 2016
@matanshukry
Copy link

I'm having a problem installing a plugin. I can see the directory is correctly copied to the /usr/src/wordpress directory, however it's not copied into the /var/www/html directory at any point.

Docker file:

FROM wordpress

COPY ["wp-subscribe","/usr/src/wordpress/wp-content/plugins/wp-subscribe"]
RUN chown -R www-data:www-data /usr/src/wordpress/wp-content/plugins/

Am I missing something?

@yosifkit
Copy link
Member

@matanshukry, anything further in your Dockerfile? The entrypoint script will copy from /usr/src/wordpress/ to /var/www/html/, but only if the conditions match (see this part in the docker-entrypoint.sh). Another thing to check is if the volume used is empty; when using things like docker-compose it tries hard to ensure that volumes get reused from run to run so you often have to remove the container and all volumes (docker-compose rm -fv wordpress) but this can delete data like uploads if you have them.

@cbarlow1993
Copy link

I've been trying no end of variations of Dockerfiles to try get this to work for a production image. I have had no luck with the examples given here so I'm wondering if there has been other changes since.

Dockerfile is:

FROM wordpress:latest

COPY --chown=www-data:www-data ./src/plugins/ /usr/src/wordpress/wp-content/plugins/
COPY --chown=www-data:www-data ./src/themes/Divi/ /usr/src/wordpress/wp-content/themes/custom-theme/
COPY --chown=www-data:www-data ./src/uploads/ /usr/src/wordpress/wp-content/uploads/
COPY --chown=www-data:www-data ./src/fonts/ /usr/src/wordpress/wp-content/uploads/et-fonts/

Anyone also had any issues with this? Surely it should be easier to embed pre-loaded plugins and themes than it currently is... unless I'm going mad and missing something, which could be the case.

@collimarco
Copy link

Is it still true that /usr/src/wordpress is copied to /var/www/html when the image is started? Can you point out where is that command in this repository?

@yosifkit
Copy link
Member

Is it still true that /usr/src/wordpress is copied to /var/www/html when the image is started? Can you point out where is that command in this repository?

Yes:

sourceTarArgs=(
--create
--file -
--directory /usr/src/wordpress
--owner "$user" --group "$group"
)
targetTarArgs=(
--extract
--file -
)
if [ "$user" != '0' ]; then
# avoid "tar: .: Cannot utime: Operation not permitted" and "tar: .: Cannot change mode to rwxr-xr-x: Operation not permitted"
targetTarArgs+=( --no-overwrite-dir )
fi
tar "${sourceTarArgs[@]}" . | tar "${targetTarArgs[@]}"
echo >&2 "Complete! WordPress has been successfully copied to $PWD"

@leocape
Copy link

leocape commented Oct 12, 2022

Should this also copy hidden files and hidden directories? In my case the hidden files and folders are not being copied across, while the other files and directories are copied correctly. If not - how can we copy the hidden files / directories?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

9 participants