Is there a workaround in appdaemon for installing libraries quicker? I’m currently using bleak, but on start-up, I have to wait for 8-10 minutes for the library to download/install.
Running a RPI4 8GB
Is there a workaround in appdaemon for installing libraries quicker? I’m currently using bleak, but on start-up, I have to wait for 8-10 minutes for the library to download/install.
Running a RPI4 8GB
Hi. Can you please provide some context so I can better understand your setup?
How are you running App daemon? As a standalone container?
Apologies, that was pretty vague. I’m running it out a docker/docker-compose with an requirements.txt file specifying bleak
Do you locally build a custom Docker image or do you directly use the official one?
In the former case you could install the dependencies from your custom requirements.txt
file as part of the Docker build, so the AppDaemon container does not have to do it at startup.
Can you post here you compose file?
Thanks for that Mion00, I’m using the office acockburn/appdaemon:latest
- extremely new to docker, I’ve made the swap from supervisor in the last couple of days so still wrapping my head around it.
My current setup is:
version: '3.0'
appdaemon:
container_name: appdaemon
restart: unless-stopped
image: acockburn/appdaemon:latest
environment:
HA_URL: ${PORT8123}
TOKEN: ${ADTOKEN}
DASH_URL: ${PORT5050}
ports:
- "5050:5050"
volumes:
- /opt/appdaemon:/conf
- /var/run/dbus:/var/run/dbus
- /opt/appdaemon/apps:/appdaemon/apps
env_file:
- ../ioc-hub/.env
depends_on:
- homeassistant
Doing some more digging, I’ve now added a Dockerfile to my appdaemon folder in an attempt to to load them as part of my docker build -
Dockerfile:
FROM acockburn/appdaemon:latest
COPY requirements.txt /opt/appdaemon/requirements.txt
RUN pip install -r /opt/appdaemon/requirements.txt
requirements.txt:
bleak==0.19.5
and added the following to my docker-compose.yaml:
build:
context: /opt/appdaemon
dockerfile: Dockerfile
Still seems to take a while, but will have a deeper dive in the morning.
The setup looks alright. Try commenting out the image
key from docker-compose.yml
.
When you use a build
section in the docker-compose I think you have to “force” it to build the local container, otherwise it fallbacks to the Docker image defined under image
.
Thanks again for explaining that @mion00 run super quick now! I ended up including a few more bits to the Dockerfile
that might be helpful to others:
FROM acockburn/appdaemon:latest
# Upgrade pip and install pip-tools
RUN pip install --upgrade pip && \
pip install --no-cache-dir pip-tools
# Create a cache directory for pip
RUN mkdir -p /pip-cache && \
pip config set global.cache-dir /pip-cache
# Copy the requirements file and install dependencies
COPY requirements.txt /opt/appdaemon/requirements.txt
RUN pip install --no-cache-dir -r /opt/appdaemon/requirements.txt
# Clean up pip cache and remove unnecessary files
RUN rm -rf /pip-cache/* && \
rm -rf /root/.cache/pip/* && \
rm -rf /var/cache/apk/* && \
rm -rf /tmp/*