在映像构建后安装wp插件

时间:2020-07-04 17:59:55

标签: wordpress docker docker-compose dockerfile wp-cli

我正在尝试在构建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安装尚不存在,并且通过指定入口点,我认为我覆盖了wordpress安装所在的官方wp映像所提供的入口点。在运行时复制到/ var / www / html目录中。不知道如何解决这个问题。

0 个答案:

没有答案