Skip to content

How should I add themes or plugins into the container? #341

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

Closed
ericandrewlewis opened this issue Oct 8, 2018 · 5 comments
Closed

How should I add themes or plugins into the container? #341

ericandrewlewis opened this issue Oct 8, 2018 · 5 comments
Labels
question Usability question, not directly related to an error with the image

Comments

@ericandrewlewis
Copy link

It's not obvious to me how I should add themes or plugins into the container. How should I do that?

I've tried making a volume in the docker-compose.yml like so:

version: '3.1'
services:
  wordpress:
    image: wordpress
    restart: always
    ports:
      - 8080:80
    volumes:
      - ./some-theme:/var/www/html/wp-content/themes/some-theme
    environment:
      WORDPRESS_DB_PASSWORD: example
  mysql:
    image: mysql:5.7
    restart: always
    environment:
      MYSQL_ROOT_PASSWORD: example

but that does not work, I assume because of a conflicting volume defined in the Dockerfile

@wglambert wglambert added the question Usability question, not directly related to an error with the image label Oct 8, 2018
@wglambert
Copy link

wglambert commented Oct 8, 2018

#246 (comment)

If you'd like a fresh install from an image to include pre-installed themes or plugins, simply add them to the source directory in /usr/src/wordpress (which is what gets copied into /var/www/html at runtime).
/var/www/html is a volume because WordPress expects to be able to self-update.

@wglambert
Copy link

Also #146
Plugins go in /usr/src/wordpress/wp-content/plugins
Themes go in /usr/src/wordpress/wp-content/themes

And then copied over in the docker-entrypoint.sh

if [ ! -e index.php ] && [ ! -e wp-includes/version.php ]; then
echo >&2 "WordPress not found in $PWD - copying now..."
if [ "$(ls -A)" ]; then
echo >&2 "WARNING: $PWD is not empty - press Ctrl+C now if this is an error!"
( set -x; ls -A; sleep 10 )
fi
tar --create \
--file - \
--one-file-system \
--directory /usr/src/wordpress \
--owner "$user" --group "$group" \
. | tar --extract --file -
echo >&2 "Complete! WordPress has been successfully copied to $PWD"

@ericandrewlewis
Copy link
Author

If you'd like a fresh install from an image to include pre-installed themes or plugins, simply add them to the source directory in /usr/src/wordpress (which is what gets copied into /var/www/html at runtime).
/var/www/html is a volume because WordPress expects to be able to self-update.

I did this in a Dockerfile:

FROM wordpress

ADD ./some-theme /usr/src/wordpress/wp-content/themes/some-theme

Built it and ran it. I don't see the local folder in the container either under /usr/src/wordpress/ or /var/www/...

Am I doing something wrong?

I would suggest we update the readme on Docker hub so it's clear how to do this after we have steps outlined.

@wglambert
Copy link

Using your Dockerfile it behaves as expected, perhaps you have some sort of permission error for the ADD to not work correctly.

docker-compose.yml

version: '3.1'

services:

  wordpress:
    image: wordpress:test
    restart: always
    ports:
      - 7070:80
    environment:
      WORDPRESS_DB_PASSWORD: example

  mysql:
    image: mysql:5.7
    restart: always
    environment:
      MYSQL_ROOT_PASSWORD: example

Dockerfile

FROM wordpress

ADD ./christmas-sweets /usr/src/wordpress/wp-content/themes/christmas-sweets
$ docker build --no-cache . -t wordpress:test
Sending build context to Docker daemon      1MB
Step 1/2 : FROM wordpress
 ---> ca0fefec932b
Step 2/2 : ADD ./christmas-sweets /usr/src/wordpress/wp-content/themes/christmas-sweets
 ---> 94d8f5c26eaf
Successfully built 94d8f5c26eaf
Successfully tagged wordpress:test

$ docker exec -it 497 bash
root@497a72d283a0:/var/www/html# ls -l wp-content/themes/
total 20
drwxr-xr-x 7 www-data www-data 4096 Oct  9 17:42 christmas-sweets
-rw-r--r-- 1 www-data www-data   28 Jun  5  2014 index.php
drwxr-xr-x 6 www-data www-data 4096 Aug  2 20:39 twentyfifteen
drwxr-xr-x 5 www-data www-data 4096 Aug  2 20:39 twentyseventeen
drwxr-xr-x 7 www-data www-data 4096 Aug  2 20:39 twentysixteen
root@497a72d283a0:/var/www/html# ls -l wp-content/themes/christmas-sweets/
total 760
-rw-r--r-- 1 www-data www-data   1573 Oct  9 17:20 comments.php
-rw-r--r-- 1 www-data www-data   1878 Oct  9 17:20 content.php
drwxr-xr-x 2 www-data www-data   4096 Oct  9 17:20 css
-rw-r--r-- 1 www-data www-data   2604 Oct  9 17:20 footer.php
-rw-r--r-- 1 www-data www-data  12974 Oct  9 17:20 functions.php
-rw-r--r-- 1 www-data www-data   2026 Oct  9 17:20 header.php
drwxr-xr-x 2 www-data www-data   4096 Oct  9 17:20 images
drwxr-xr-x 2 www-data www-data   4096 Oct  9 17:20 inc
-rw-r--r-- 1 www-data www-data   3146 Oct  9 17:20 index.php
drwxr-xr-x 2 www-data www-data   4096 Oct  9 17:20 js
-rw-r--r-- 1 www-data www-data   5637 Oct  9 17:20 readme.txt
-rw-r--r-- 1 www-data www-data 647548 Oct  9 17:20 screenshot.png
-rw-r--r-- 1 www-data www-data    442 Oct  9 17:20 sidebar-shop.php
-rw-r--r-- 1 www-data www-data    436 Oct  9 17:20 sidebar.php
-rw-r--r-- 1 www-data www-data    872 Oct  9 17:20 singular.php
-rw-r--r-- 1 www-data www-data  47213 Oct  9 17:20 style.css
drwxr-xr-x 2 www-data www-data   4096 Oct  9 17:20 templates

root@497a72d283a0:/var/www/html# ls -l /usr/src/wordpress/wp-content/themes/christmas-sweets/
total 760
-rw-r--r-- 1 root root   1573 Oct  9 17:20 comments.php
-rw-r--r-- 1 root root   1878 Oct  9 17:20 content.php
drwxr-xr-x 2 root root   4096 Oct  9 17:20 css
-rw-r--r-- 1 root root   2604 Oct  9 17:20 footer.php
-rw-r--r-- 1 root root  12974 Oct  9 17:20 functions.php
-rw-r--r-- 1 root root   2026 Oct  9 17:20 header.php
drwxr-xr-x 2 root root   4096 Oct  9 17:20 images
drwxr-xr-x 2 root root   4096 Oct  9 17:20 inc
-rw-r--r-- 1 root root   3146 Oct  9 17:20 index.php
drwxr-xr-x 2 root root   4096 Oct  9 17:20 js
-rw-r--r-- 1 root root   5637 Oct  9 17:20 readme.txt
-rw-r--r-- 1 root root 647548 Oct  9 17:20 screenshot.png
-rw-r--r-- 1 root root    442 Oct  9 17:20 sidebar-shop.php
-rw-r--r-- 1 root root    436 Oct  9 17:20 sidebar.php
-rw-r--r-- 1 root root    872 Oct  9 17:20 singular.php
-rw-r--r-- 1 root root  47213 Oct  9 17:20 style.css
drwxr-xr-x 2 root root   4096 Oct  9 17:20 templates

@ericandrewlewis
Copy link
Author

Using your Dockerfile it behaves as expected, perhaps you have some sort of permission error for the ADD to not work correctly.

Yeah huh I'm not sure what went wrong there. I am able to get it working now 😄

I would suggest we add instructions for adding themes and plugins into the docs README. Should I open an issue on that repository?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Usability question, not directly related to an error with the image
Projects
None yet
Development

No branches or pull requests

2 participants