Open Daenara opened 4 years ago
You could save a lot of container size by using one of the slim images. https://hub.docker.com/_/python 3.8-slim for example
I did that while testing but it took 3 times longer just to install the apt packages needed so I decided I personally don't have a space issue and I prefer it to be built faster instead.
Based on @Daenara 's Dockerfile, I created an alternative, based on Alpine Linux. Tested on a Raspberry Pi Zero W with Respeaker 2 and Rhasspy.
FROM arm32v6/python:3.9.1-alpine3.12
ARG USER=docker
ARG FOLDER=/home/$USER
ARG VENV=venv
ARG FOLDER_NAME=hermesLedControl
RUN set -ex && adduser --uid 1000 --disabled-password --gecos '' $USER && \
delgroup ping && \
addgroup --gid 997 --system gpio && \
addgroup --gid 999 --system spi && \
addgroup $USER gpio && \
addgroup $USER spi
WORKDIR /home/docker
RUN set -ex && \
apk add --no-cache \
curl \
grep && \
export VERSION=$(curl --silent "https://api.github.com/repos/project-ali ce-assistant/HermesLedControl/releases/latest" | grep -Po '"tag_name": "\K.*?(?= ")') && \
apk update && apk add \
git \
mosquitto \
mosquitto-clients \
portaudio-dev && \
rm -rf /var/lib/apt/lists/* && \
pip3 --no-cache-dir install virtualenv && \
mkdir -p ${FOLDER_NAME} && \
wget $(curl --silent "https://api.github.com/repos/project-alice-assista nt/HermesLedControl/releases/latest" | grep -Po '"tarball_url": "\K.*?(?=")') && \
tar -xzf ${VERSION} -C ${FOLDER_NAME} --strip-components=1 && \
rm ${VERSION} && \
mkdir -p ${FOLDER}/${FOLDER_NAME}/logs && \
chown -R ${USER} ${FOLDER}/${FOLDER_NAME}
RUN set -ex && \
apk add --no-cache \
gcc \
musl-dev \
linux-headers
USER $USER
RUN set -ex && \
virtualenv -p python3 ${FOLDER}'/'${FOLDER_NAME}'/'${VENV}
ENV PATH="${FOLDER}'/'${FOLDER_NAME}'/'${VENV}/bin:$PATH"
RUN pip3 --no-cache-dir install RPi.GPIO && \
pip3 --no-cache-dir install spidev && \
pip3 --no-cache-dir install gpiozero && \
pip3 --no-cache-dir install paho-mqtt && \
pip3 --no-cache-dir install toml
RUN pip3 --no-cache-dir install pyyaml
WORKDIR ${FOLDER}/${FOLDER_NAME}
ENTRYPOINT python3 main.py ${HLC_ARGUMENTS}
@michelcve out of curiosity: whats your container image size? Total or even for each step?
Additionally you can chain pip installs: pip3 --no-cache-dir install RPi.GPIO spidev gpiozero ...
export VERSION=$(curl --silent "https://api.github.com/repos/project-ali
And it seams its cut of somewhat 🤔
Thanks a lot for these Dockerfiles! Is it possible to use them with --enableDOA=True
in theory?
Is your feature request related to a problem? Please describe. I build my smart home system in docker containers so I can easily move them to more powerful hardware if needed. Since this doesn't have an official docker file I wrote one.
Describe the solution you'd like I would like it if this project somehow incorporates the docker file, either by integrating it, or leaving this issue here for others to find if they want to run this in a docker. My Dockerfile might not be perfect but it runs.
Additional context I used the download script and the install script to write this so it always gets the latest release. I did omit the version number in the folder name and the removal of the last version because the docker is always built from scratch anyway. I did not test if the GPIO led support works but in theory it should, because all the devices I encountered so far for GPIO are in the docker-compose and the user I add for the docker gets the gpio group.
Dockerfile:
docker-compose integration: