[bitnami/wordpress] Deploying WordPress on Minikube. Error executing 'postInstallation': EEXIST: file already exists
Which chart: Wordpress
Description
I'm trying to deploy a WordPress instance with custom plugins and theme on Minikube, following this tutorial.
On performing helm install with my custom values-production.yaml (below), the wordpress pod keeps falling into a CrashLoopBackOff. This happens because the wordpress container fails with a EEXIST: file already exists error.
Detail of error:
wordpre TRACE [prepareDataToPersist] Preparing /opt/bitnami/wordpress/wp-content to persist in /bitnami/wordpress/wp-content
Error executing 'postInstallation': EEXIST: file already exists, symlink '/bitnami/wordpress/wp-content' -> '/opt/bitnami/wordpress/wp-content'
nami TRACE Error: Error executing 'postInstallation': EEXIST: file already exists, symlink '/bitnami/wordpress/wp-content' -> '/opt/bitnami/wordpress/wp-content'
at Object.fs.symlinkSync (fs.js:1014:18)
at Object.link (/opt/bitnami/nami/node_modules/nami-utils/lib/file/link.js:34:8)
at Object.<anonymous> (/opt/bitnami/nami/node_modules/lodash/index.js:51:276)
at _.each (/.nami/components/com.bitnami.wordpress/lib/volume.js:132:13)
at r (/opt/bitnami/nami/node_modules/lodash/index.js:5:348)
at Function.sf (/opt/bitnami/nami/node_modules/lodash/index.js:78:256)
at Function.<anonymous> (/opt/bitnami/nami/node_modules/lodash/index.js:51:276)
at Object.prepareDataToPersist (/.nami/components/com.bitnami.wordpress/lib/volume.js:121:7)
at Component.$app.postInstallation (/.nami/components/com.bitnami.wordpress/main.js:99:21)
at Component.runStep (/opt/bitnami/nami/node_modules/nami-core/lib/components/component.js:159:12)
When building the image and running it with docker-compose, following the previous tutorial, everything worked well (note: in this case, I did not recover the original WP user with USER 1001 in Dockerfile).
What I've tried
-
I've tried with and without recovering the original WP user by inserting (and removing)
USER 1001inDockerfile. -
I've tried changing permissions as per #3253, with
RUN sudo chmod -R g+w /opt/bitnami/wordpress/wp-contentinDockerfile. But when building the Docker Image with this layer, the build process gets stuck here. It doesn't move to the next step.
My configuration
I'm running things from a Ubuntu distro in WSL2.
Dockerfile:
COPY rootfs /
ADD plugins /opt/bitnami/wordpress/wp-content/plugins
ADD themes /opt/bitnami/wordpress/wp-content/themes
RUN bash download-extra.sh
(...)
EXPOSE 8080 8443
RUN sudo chmod -R g+w /opt/bitnami/wordpress/wp-content # I've tried both with and without this layer
USER 1001 # I've tried both with and without this layer
ENTRYPOINT [ "/app-entrypoint.sh" ]
Note: In the Dockerfile, I ADD my custom plugins and theme from the plugins and themes folders because they aren't in a public repository, since they are proprietary.
download-extra.sh:
#!/bin/bash
# Download and unzip publicly available plugins
curl -o /tmp/woocommerce.4.7.0.zip https://downloads.wordpress.org/plugin/woocommerce.4.7.0.zip
curl -o /tmp/ajax-search-for-woocommerce.1.8.0.zip https://downloads.wordpress.org/plugin/ajax-search-for-woocommerce.1.8.0.zip
curl -o /tmp/easy-wp-smtp.zip https://downloads.wordpress.org/plugin/easy-wp-smtp.zip
curl -o /tmp/google-sitemap-generator.4.1.1.zip https://downloads.wordpress.org/plugin/google-sitemap-generator.4.1.1.zip
curl -o /tmp/redirection.4.9.2.zip https://downloads.wordpress.org/plugin/redirection.4.9.2.zip
unzip /tmp/woocommerce.4.7.0.zip -d /opt/bitnami/wordpress/wp-content/plugins
unzip /tmp/ajax-search-for-woocommerce.1.8.0.zip -d /opt/bitnami/wordpress/wp-content/plugins
unzip /tmp/easy-wp-smtp.zip -d /opt/bitnami/wordpress/wp-content/plugins
unzip /tmp/google-sitemap-generator.4.1.1.zip -d /opt/bitnami/wordpress/wp-content/plugins
unzip /tmp/redirection.4.9.2.zip -d /opt/bitnami/wordpress/wp-content/plugins
# Unzip private plugins and themes, previously copied to container
unzip /opt/bitnami/wordpress/wp-content/plugins/woocommerce-min-max-quantities.zip -d /opt/bitnami/wordpress/wp-content/plugins
unzip /opt/bitnami/wordpress/wp-content/plugins/woocommerce-composite-products.zip -d /opt/bitnami/wordpress/wp-content/plugins
unzip /opt/bitnami/wordpress/wp-content/plugins/casatrend-plugin.zip -d /opt/bitnami/wordpress/wp-content/plugins
unzip /opt/bitnami/wordpress/wp-content/themes/casatrend-theme.zip -d /opt/bitnami/wordpress/wp-content/themes
# Delete zip files
rm /opt/bitnami/wordpress/wp-content/plugins/woocommerce-min-max-quantities.zip
rm /opt/bitnami/wordpress/wp-content/plugins/woocommerce-composite-products.zip
rm /opt/bitnami/wordpress/wp-content/plugins/casatrend-plugin.zip
rm /opt/bitnami/wordpress/wp-content/themes/casatrend-theme.zip
app-entrypoint.sh:
#!/bin/bash -e
. /opt/bitnami/base/functions
. /opt/bitnami/base/helpers
print_welcome_page
if [[ "$1" == "nami" && "$2" == "start" ]] || [[ "$1" == "httpd" ]]; then
. /apache-init.sh
. /wordpress-init.sh
nami_initialize apache php mysql-client wordpress
/opt/bitnami/wp-cli/bin/wp plugin activate woocommerce
/opt/bitnami/wp-cli/bin/wp plugin activate woocommerce-composite-products
/opt/bitnami/wp-cli/bin/wp plugin activate woocommerce-min-max-quantities
/opt/bitnami/wp-cli/bin/wp plugin activate ajax-search-for-woocommerce
/opt/bitnami/wp-cli/bin/wp plugin activate easy-wp-smtp
/opt/bitnami/wp-cli/bin/wp plugin activate google-sitemap-generator
/opt/bitnami/wp-cli/bin/wp plugin activate redirection
/opt/bitnami/wp-cli/bin/wp plugin activate ct-plugin
/opt/bitnami/wp-cli/bin/wp theme activate casatrend
info "Starting wordpress... "
info "Starting gosu... "
. /post-init.sh
fi
exec tini -- "$@"
values-production.yaml:
## Global Docker image parameters
## Please, note that this will override the image parameters, including dependencies, configured to use the global value
## Current available global Docker image parameters: imageRegistry and imagePullSecrets
##
global:
imageRegistry: docker.io
imagePullSecrets:
- regcred
# storageClass: myStorageClass
## Bitnami WordPress image version
## ref: https://hub.docker.com/r/bitnami/wordpress/tags/
##
image:
registry: docker.io
repository: goncalovf/casatrend-wordpress
tag: latest
## Specify a imagePullPolicy
## Defaults to 'Always' if image tag is 'latest', else set to 'IfNotPresent'
## ref: http://kubernetes.io/docs/user-guide/images/#pre-pulling-images
##
pullPolicy: IfNotPresent
## Optionally specify an array of imagePullSecrets.
## Secrets must be manually created in the namespace.
## ref: https://kubernetes.io/docs/tasks/configure-pod-container/pull-image-private-registry/
##
# pullSecrets:
# - regcred
## Set to true if you would like to see extra information on logs
##
debug: true
(...)
Note that I add a imagePullSecrets in the Global parameters, named regcred, because the image is proprietary. It's stored in Docker Hub.
Related Issues
Hi @goncalovf, the initialization script needs /opt/bitnami/wordpress/wp-content to not exists but you are creating it at build time, this is the error.
I think you could move all this logic to the initialization part at
if [[ "$1" == "nami" && "$2" == "start" ]] || [[ "$1" == "httpd" ]]; then
. /apache-init.sh
. /wordpress-init.sh
nami_initialize apache php mysql-client wordpress
./download_and_install_plugins.sh
info "Starting wordpress... "
info "Starting gosu... "
. /post-init.sh
fi
and ADD those proprietary plugins to a different path
ADD plugins /opt/bitnami/my-plugins
ADD themes /opt/bitnami/my-themes
Then in the ./download_and_install_plugins.sh move them to the proper folder.
You can use this file to avoid executing this script every time you restart the container:
$ ls -la bitnami/wordpress/.initialized
-rw-r--r-- 1 1001 1001 0 Nov 27 16:18 bitnami/wordpress/.initialized
Thanks!
Hi @dani8art. Thank you very very much for your input. It solved my issue. Thanks!
Still, I did not understand the part about using bitnami/wordpress/.initialized to avoid executing the script every time I restart the container. Can you point me to some relevant documentation? Thank you again!
I just read a comment on another issue that explains my doubt about bitnami/wordpress/.initialized. I'm going to close this issue now. Thank you again for your support!