I
I
Islam Ibakaev2021-10-07 11:58:13
WordPress
Islam Ibakaev, 2021-10-07 11:58:13

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

In docker-compose I bind /var/www/html to /public
./public:/var/www/html:delegated
That is, I expect to see a folder with wordpress files in /public/wordpress
However, after the build, the /public folder remains empty, as if the archive with the files is not loaded. I looked at the app
container (docker-compose exec app bash), it's empty, although I indicated the unpacking there (see above) Can you please tell me what I'm missing? Below is a screen shot of the WordPress upload step. Judging by the screenshot, the archive is being loaded, but where is the folder with the files then? ps Link to the repository, if you want to raise the project.
&& tar -xzf wordpress.tar.gz -C /var/www/html \

615eb76dca909377039299.png

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexander Karabanov, 2021-10-07
@karabanov

~$ 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
...

There were no difficulties. You're doing something wrong...
UPD
And it's clear what's wrong.
If you look in /usr/local/bin/docker-entrypoint.sh you will see there in particular:
docker-entrypoint.sh
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

You need to do the same. Or use /usr/local/bin/docker-entrypoint.sh from the official image.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question