0

I'm trying to install wp plugins by executing script right after the wordpress image is built.

Here is my Dockerfile:

FROM wordpress

# Update aptitude with new repo
RUN apt-get update

# Install software
RUN apt-get install -y sudo vim curl less git python-dev python3.5

# Add WP-CLI
 RUN curl -o /bin/wp-cli.phar https://raw.githubusercontent.com/wp-cli/builds/gh-pages/phar/wp-cli.phar
 COPY wp-su.sh /bin/wp
 RUN chmod +x /bin/wp-cli.phar /bin/wp && chown www-data:www-data /bin/wp-cli.phar /bin/wp

# Copy scripts into the image
 COPY install.py /usr/src/wordpress
 COPY plugins.json /usr/src/wordpress
 COPY wait-for-it.sh /usr/src/wordpress
 RUN chmod +x /usr/src/wordpress/install.py
 RUN chmod +x /usr/src/wordpress/plugins.json
 RUN chmod +x /usr/src/wordpress/wait-for-it.sh


COPY --chown=www-data:www-data uploads/ /usr/src/wordpress/wp-content/uploads


# Cleanup
RUN apt-get clean
RUN rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*

ENTRYPOINT ["/usr/src/wordpress/wait-for-it.sh", "db:3306", "--", "python" , "/usr/src/wordpress/install.py" ]
CMD ["apache2-foreground"]

Once the scripts runs I get the following error:

Error: This does not seem to be a WordPress installation.
Pass --path=`path/to/wordpress` or run `wp core download`.

I tried doing what the error suggested but it did not work. The wordpress installation from my understanding should be located at /usr/src/wordpress along with all the scripts I copied into it. Is what I'm doing correct ? Should it even be possible to do what I'm attempting ? Any help would be appreciated.

Note: This image is run from docker-compose.yml

UPDATE:

Looks to me like the reason for the above error is because the wordpress installation isn't there yet and by specifying the entrypoint I think I'm overwriting the entry point that is provided by the official wp image in which wordpress installation is copied into /var/www/html directory at runtime. Not sure how to get around this.

Lance
  • 1
  • 2
  • I'm not super familiar with WP installations, but is there a reason you aren't using the [WP images](https://hub.docker.com/_/wordpress/)? – ladygremlin Jul 04 '20 at 20:08
  • I am using a wordpress image. The Dockerfile pulls the latest image from the repository and I'm just making modifications to it. – Lance Jul 04 '20 at 20:22

0 Answers0