<p>I have a custom module that I want to install on a container running the <strong>bitnami/magento</strong> docker image within a kubernetes cluster.</p>

<p>I am currently trying to install the module from a local dir into the containers <strong>Dockerfile</strong>:</p>

<pre><code># 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
</code></pre>

<p>After building and running this image the site pings back a 500 error. The pod logs show that Magento installs correctly but it doesn't know what to do with the custom module:</p>

<blockquote>
  <p>Exception #0 (UnexpectedValueException): Setup version for module 'Foo_Bar' is not specified</p>
</blockquote>

<p>Therefore to get things working I have to open a shell to the container and run some commands:</p>

<pre><code>$ php /opt/bitnami/magento/htdocs/bin/magento setup:upgrade

$ chown -R bitnami:daemon /opt/bitnami/magento/htdocs
</code></pre>

<p>The first sorts the magento set up issue, the second ensures the next time an http request comes in Magento is able to correctly generate any directories and files it needs.</p>

<p>This gives me a functioning container, however, kubernetes is not able to rebuild this container as I am manually running a bunch of commands after Magento has installed.</p>

<p>I thought about running the above commands within the containers <strong>readinessProbe</strong> however not sure if it would work as not 100% on the state of Magento when that is first called, alongside it seeming very hacky.</p>

<p>Any advice on how to best set up custom modules within a bitnami/magento container would be much appreciated.</p>

<p>UPDATE:</p>

<p>Since opening this issue I've been discussing it further on Github: <a href="https://github.com/bitnami/bitnami-docker-magento/issues/82" rel="nofollow noreferrer">https://github.com/bitnami/bitnami-docker-magento/issues/82</a></p>

GuyC
<p>I've got it working via the use of composer instead of manually adding the module to the app/code directory.</p>

<p>I was able to do this by firstly adding the module to Packagist, then I stored my Magento Marketplace authentication details in auth.json:</p>

<pre><code>{
    "http-basic": {
        "repo.magento.com": {
            "username": &lt;MAGENTO_MARKETPLACE_PUBLIC_KEY&gt;,
            "password": &lt;MAGENTO_MARKETPLACE_PRIVATE_KEY&gt;
        }
    }
}
</code></pre>

<p>You can get the public &amp; private key values by creating a new access key within marketplace. Place the file in the modules root, alongside your <strong>composer.json</strong>.</p>

<p>Once I had that I updated my Dockerfile to use the auth.json and require the custom module:</p>

<pre><code># 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
</code></pre>

<p>I then completed a new install, creating the db container alongside the magento container. However it should also work fine with an existing db so long as the modules versions are the same.</p>
