Problem with local addon using gpio on raspberry pi

I have a set of scripts that use rpitx to control a ceiling fan. If I create a container from the image and run it on my own through docker everything works fine. When I run it as an addon and invoke the scripts the whole pi becomes inaccessible and needs to be restarted.

The scripts are invoked via hitting http end-points served by lighttpd. The following are my configuration files.

config.json

{
  "name": "Family Room Fan Server",
  "slug": "family_room_fan_server",
  "description": "Runs the family room fan server so the client in HA can access it",
  "version": "1",
  "arch": ["armhf", "armv7", "aarch64", "amd64", "i386"],
  "startup": "before",
  "boot": "auto",
  "ports": {
    "8000/tcp":8800
  },
  "gpio": true,
  "devices": ["/dev/mem:/dev/mem:rwm"],
  "privileged": ["SYS_RAWIO"],
  "options": {},
  "schema": {},
  "apparmor": false
}

Dockerfile

FROM homeassistant/armhf-base-raspbian:latest

ENV LANG C.UTF-8

RUN apt-get update
RUN apt-get install -y lighttpd sudo
RUN mkdir /var/www/html/cgi-bin
RUN echo "www-data        ALL=NOPASSWD : ALL" >> /etc/sudoers

COPY family_room_fan/* /var/www/html/cgi-bin/
COPY lighttpd.conf /etc/lighttpd/lighttpd.conf
COPY run.sh /run.sh

RUN chmod a+x /run.sh

CMD ["/run.sh"]

run.sh

#!/usr/bin/env bashio

lighttpd -D -f /etc/lighttpd/lighttpd.conf