I'm trying to copy the final WordPress files from the official WordPress Docker image, from an initContainer into an emptyDir volume. I expect the emptyDir volume to contain the entire WordPress installation so I can share this between containers. Instead I only get the wp-contents folder with no content. No other files or folders are copied over.
After reviewing the WordPress Dockerfile and entrypoint, I suspect the entrypoint is not getting executed because the Dockerfile has instructions to create the wp-content folder in /var/www/html, but it seems like nothing within the entrypoint is getting executed.
I have tried changing my args: to args: ["sh", "-c", "sleep 60 && cp -r /var/www/html/. /shared-wordpress"] in hopes that the container just needed some time to finish running through the entrypoint before I run the cp command, but that has no effect. If you inspect the /shared-wordpress mount in the running wordpress container, it only shows the wp-content folder.
Copying the WordPress files from /usr/src/wordpress works great with the exception that it does NOT include the generated wp-config.php file. I need all the WordPress files along with the generated wp-config.php file.
apiVersion: apps/v1
kind: Deployment
metadata:
name: wordpress
labels:
app: wordpress
spec:
selector:
matchLabels:
app: wordpress
template:
metadata:
labels:
app: wordpress
spec:
containers:
- name: wordpress
image: wordpress:5.5.1-php7.4-fpm-alpine
volumeMounts:
- name: shared-wordpress
mountPath: /shared-wordpress
initContainers:
- name: init-wordpress
image: wordpress:5.5.1-php7.4-fpm-alpine
env:
- name: WORDPRESS_DB_HOST
value: test_host
- name: WORDPRESS_DB_USER
value: root
- name: WORDPRESS_DB_PASSWORD
value: hw8djdl21ds
- name: WORDPRESS_DB_NAME
value: local_wordpress
- name: WORDPRESS_DEBUG
value: "1"
- name: WORDPRESS_CONFIG_EXTRA
value: "define( 'FS_METHOD', 'direct' );"
args: ["/bin/sh", "-c", "cp -r /var/www/html/. /shared-wordpress"]
volumeMounts:
- name: shared-wordpress
mountPath: /shared-wordpress
volumes:
- name: shared-wordpress
emptyDir: {}