Docker 在kubernetes上使用带有bitnami/magento容器的自定义模块
我想在kubernetes集群中运行bitnami/magentodocker映像的容器上安装一个自定义模块 我当前正在尝试将模块从本地目录安装到容器Dockerfile:Docker 在kubernetes上使用带有bitnami/magento容器的自定义模块,docker,magento,kubernetes,magento2,bitnami,Docker,Magento,Kubernetes,Magento2,Bitnami,我想在kubernetes集群中运行bitnami/magentodocker映像的容器上安装一个自定义模块 我当前正在尝试将模块从本地目录安装到容器Dockerfile: # run bitnami's magento container FROM bitnami/magento:2.2.5-debian-9 # add magento_code directory to the bitnami magento install # ./magento_data/code contains t
# run bitnami's magento container
FROM bitnami/magento:2.2.5-debian-9
# add magento_code directory to the bitnami magento install
# ./magento_data/code contains the module, i.e. Foo/Bar
ADD ./magento_data/code /opt/bitnami/magento/htdocs/app/code
构建并运行此映像后,站点ping返回500错误。pod日志显示Magento安装正确,但不知道如何处理自定义模块:
# run bitnami's magento container
FROM bitnami/magento:2.2.5
# Require custom modules
WORKDIR /opt/bitnami/magento/htdocs/
ADD ./auth.json .
RUN composer require foo/bar
异常#0(意外值异常):未指定模块“Foo#u Bar”的安装版本
因此,要使事情正常进行,我必须打开容器的外壳并运行一些命令:
$ php /opt/bitnami/magento/htdocs/bin/magento setup:upgrade
$ chown -R bitnami:daemon /opt/bitnami/magento/htdocs
第一种方法对magento设置问题进行排序,第二种方法确保下次http请求传入magento时能够正确生成所需的任何目录和文件
这给了我一个功能正常的容器,但是,kubernetes无法重建这个容器,因为我在安装Magento后手动运行了一系列命令
我曾考虑在容器readinessProbe中运行上述命令,但不确定在第一次调用Magento时,它是否会在Magento状态下100%正常工作,同时看起来非常粗糙
对于如何在bitnami/magento容器中最好地设置自定义模块,如有任何建议,将不胜感激
更新:
自从打开这个问题以来,我一直在Github上进一步讨论它:我通过使用composer使它工作,而不是手动将模块添加到app/code目录 我首先将模块添加到PackageGist,然后将我的Magento Marketplace身份验证详细信息存储在auth.json中:
{
"http-basic": {
"repo.magento.com": {
"username": <MAGENTO_MARKETPLACE_PUBLIC_KEY>,
"password": <MAGENTO_MARKETPLACE_PRIVATE_KEY>
}
}
}
然后我完成了一个新的安装,在magento容器旁边创建了db容器。但是,只要模块版本相同,它在现有数据库中也可以正常工作