Ability to configure container target path for custom Addon (Such as WordPress)

I’ve been building some custom addons and for some applications it is best to use some existing Docker images for the addon. One example in particular is WordPress.

I have created a WordPress addon using the following config.yaml:

name: "Addon Name"
description: "Addon Description"
version: "latest"
slug: "addon-slug"
init: false
arch:
  - aarch64
  - amd64
  - armhf
  - armv7
  - i386
ports:
  80/tcp: 8080
image: docker.io/wordpress

That’s it. That’s the entire Addon. It doesn’t even need a dockerfile. With Home Assistant OS, Put that config.yaml file in a folder in the “Addons” share and it will install and run successfully. (You will need a mySQL addon like MariaDB for the database portion)

The problem is that as soon as the Addon restarts, everything is wiped out and it reinstalls WordPress. This is because WordPress installs the website to the /var/www/html directory which is not mapped outside of the Addon container. At this point I took the dockerfile used to create the WordPress image and tried to tweak it to use the /data directory but this just resulted in all sorts of issues due to the somewhat hardcoded nature of the /var/www/html directory. And I found this to be true for other addons as well (Drupal for example)

This feature request is to add the ability to configure the internal or “target” path of the data or addon_config mapping.

Example config.yaml of what the map might look like (not sure if this is the best way but just to convey the idea):

map:
  - share:rw
  - name: data
    target: /var/www/html
  - name: addon_config:rw
    target: /custom/config/path

I’m not sure if this will be helpful for anyone, but I dug into the code a little bit and I think this is where the new target config value would get set:

Thanks for all that you do with this amazing application!

Hi!
I’m sure you can install Portainer add-on and then install any docker you want just as usual, without add on hassle.
However TBH, I can’t recommended mixing services like that, better a different mini PC or VM if you can.

Thanks for the reply! To solve this issue in the meantime I am actually already using Portainer to update the bind path. Understandably, this is not a supported solution and is not something the average user could or should do.

In fact, In the few weeks since I created these unsupported containers I have encountered several stability issues where the entire OS crashes.

I disagree that this is a mixing of services. WordPress is simply an Apache web server that connects to a database backend which is similar to many other Addons. Hosting a personal website as part of a home automation suite seems to fit the scope of what Home Assistant Addons were designed for.

This feature request has been implemented in Home Assistant with the completion of this pull request:

For some reason (as of today) the documentation pull request for this change has yet to be merged. For anyone that stumbles upon this and would like to configure the target paths for Addon containers please refer to this documentation pull request:

1 Like