Answer the question
In order to leave comments, you need to log in
Why is the WordPress archive not loading?
I'm trying to write a docker blank for wordpress. I know that there is an official wordpress image, but there are rights issues. Moreover, if you want to bring an existing project to the docker, then the finished image is unlikely to help. The finished image, as far as I understand, is only suitable for a project from scratch.
In general, in the app.dockerfile, I seem to upload an archive with WordPress files and unpack the folder to /var/www/html
RUN curl -o wordpress.tar.gz -SL https://wordpress.org/latest.tar.gz \
&& tar -xzf wordpress.tar.gz -C /var/www/html \
&& rm wordpress.tar.gz
./public:/var/www/html:delegated
&& tar -xzf wordpress.tar.gz -C /var/www/html \
Answer the question
In order to leave comments, you need to log in
~$ mkdir ./public
~$ ls -1 ./public
~$
~$ cat docker-compose.yml
version: "2.3"
services:
wp_site:
image: "wordpress:php8.0-fpm"
container_name: "wordpress"
volumes:
- "./public:/var/www/html:delegated"
~$ docker-compose up -d
~$ ls -1 public/
index.php
license.txt
readme.html
...
if [ ! -e index.php ] && [ ! -e wp-includes/version.php ]; then
# if the directory exists and WordPress doesn't appear to be installed AND the permissions of it are root:root, let's chown it (likely a Docker-created directory)
if [ "$uid" = '0' ] && [ "$(stat -c '%u:%g' .)" = '0:0' ]; then
chown "$user:$group" .
fi
echo >&2 "WordPress not found in $PWD - copying now..."
if [ -n "$(find -mindepth 1 -maxdepth 1 -not -name wp-content)" ]; then
echo >&2 "WARNING: $PWD is not empty! (copying anyhow)"
fi
sourceTarArgs=(
--create
--file -
--directory /usr/src/wordpress
--owner "$user" --group "$group"
)
targetTarArgs=(
--extract
--file -
)
if [ "$uid" != '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
# loop over "pluggable" content in the source, and if it already exists in the destination, skip it
# https://github.com/docker-library/wordpress/issues/506 ("wp-content" persisted, "akismet" updated, WordPress container restarted/recreated, "akismet" downgraded)
for contentPath in \
/usr/src/wordpress/.htaccess \
/usr/src/wordpress/wp-content/*/*/ \
; do
contentPath="${contentPath%/}"
[ -e "$contentPath" ] || continue
contentPath="${contentPath#/usr/src/wordpress/}" # "wp-content/plugins/akismet", etc.
if [ -e "$PWD/$contentPath" ]; then
echo >&2 "WARNING: '$PWD/$contentPath' exists! (not copying the WordPress version)"
sourceTarArgs+=( --exclude "./$contentPath" )
fi
done
tar "${sourceTarArgs[@]}" . | tar "${targetTarArgs[@]}"
echo >&2 "Complete! WordPress has been successfully copied to $PWD"
fi
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question