首页 > 解决方案 > 图像构建后安装 wp 插件

问题描述

我正在尝试通过在构建 wordpress 图像后立即执行脚本来安装 wp 插件。

这是我的 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"]

脚本运行后,我收到以下错误:

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

我尝试按照错误提示进行操作,但没有成功。据我了解,wordpress 安装应该/usr/src/wordpress与我复制到其中的所有脚本一起放置。我在做什么正确吗?是否有可能做我正在尝试的事情?任何帮助,将不胜感激。

注意:此图像是从 docker-compose.yml 运行的

更新:

在我看来,上述错误的原因是因为尚未安装 wordpress,并且通过指定入口点,我认为我正在覆盖官方 wp 图像提供的入口点,其中 wordpress 安装被复制到 /运行时的 var/www/html 目录。不知道如何解决这个问题。

标签: wordpressdockerdocker-composedockerfilewp-cli

解决方案


推荐阅读