ARG BUILD_FROM=ghcr.io/hassio-addons/debian-base/amd64:5.0.0 # hadolint ignore=DL3006 FROM ${BUILD_FROM} # Confiure locale ENV \ LANG=en_US.UTF-8 \ LANGUAGE=en_US:en \ LC_ALL=en_US.UTF-8 # Set shell SHELL ["/bin/bash", "-o", "pipefail", "-c"] # Copy Python requirements file COPY requirements.txt /tmp/requirements.txt # Copy in extensions list COPY vscode.extensions /root/vscode.extensions # Setup base system ARG BUILD_ARCH=amd64 # hadolint ignore=SC2181, DL3008 RUN \ apt-get update \ \ && apt-get install -y --no-install-recommends \ ack=3.4.0-1 \ libarchive-tools=3.4.3-2+b1 \ build-essential=12.9 \ colordiff=1.0.18-1.1 \ git=1:2.30.2-1 \ iputils-ping=3:20210202-1 \ locales=2.31-13 \ mariadb-client=1:10.5.11-1 \ mosquitto-clients=2.0.11-1 \ net-tools=1.60+git20181103.0eebece-1 \ nmap=7.91+dfsg1+really7.80+dfsg1-2 \ openssh-client=1:8.4p1-5 \ openssl=1.1.1k-1 \ python3-dev=3.9.2-3 \ python3=3.9.2-3 \ unzip=6.0-26 \ uuid-runtime=2.36.1-8 \ wget>=1.21-1 \ zip=3.0-12 \ zsh=5.8-6+b2 \ \ && sed -i -e 's/# en_US.UTF-8 UTF-8/en_US.UTF-8 UTF-8/' /etc/locale.gen \ && locale-gen \ \ && curl https://bootstrap.pypa.io/get-pip.py | python3 \ \ && if [[ "${BUILD_ARCH}" = "aarch64" ]]; then ARCH="arm64"; fi \ && if [[ "${BUILD_ARCH}" = "amd64" ]]; then ARCH="amd64"; fi \ && curl -J -L -o /tmp/code.tar.gz \ "https://github.com/cdr/code-server/releases/download/v3.11.1/code-server-3.11.1-linux-${ARCH}.tar.gz" \ && mkdir -p /usr/local/lib/code-server \ && tar zxvf \ /tmp/code.tar.gz \ --strip 1 -C /usr/local/lib/code-server \ \ && ln -s /usr/local/lib/code-server/bin/code-server /usr/local/bin/code-server \ && ln -s /usr/local/lib/code-server/bin/code-server /usr/local/bin/code \ \ && mkdir -p /root/.code-server/extensions \ && uuid=$(uuidgen) \ && while read -r ext; do \ extention="${ext%%#*}" \ vendor="${extention%%.*}"; \ slug="${extention#*.}"; \ version="${ext##*#}"; \ \ echo "Installing vscode extension: ${slug} by ${vendor} @ ${version} "; \ \ echo "https://marketplace.visualstudio.com/_apis/public/gallery/publishers/${vendor}/vsextensions/${slug}/${version}/vspackage"; \ curl -JL --retry 5 -o "/tmp/${extention}-${version}.vsix" \ -H "User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/79.0.3945.130 Safari/537.36" \ -H "x-market-user-id: ${uuid}" \ "https://marketplace.visualstudio.com/_apis/public/gallery/publishers/${vendor}/vsextensions/${slug}/${version}/vspackage"; \ mkdir -p "/root/.code-server/extensions/${extention}-${version}"; \ bsdtar --strip-components=1 -xf "/tmp/${extention}-${version}.vsix" \ -C "/root/.code-server/extensions/${extention}-${version}" extension; \ [ $? -ne 0 ] && exit 1; \ sleep 1; \ done < /root/vscode.extensions \ && ls -la /root/.code-server/extensions/ \ \ && curl -L -s -o /usr/bin/ha \ "https://github.com/home-assistant/cli/releases/download/4.12.3/ha_${BUILD_ARCH}" \ && chmod a+x /usr/bin/ha \ \ && git clone --branch master --single-branch --depth 1 \ "git://github.com/robbyrussell/oh-my-zsh.git" ~/.oh-my-zsh \ \ && git clone --branch master --single-branch --depth 1 \ "git://github.com/zsh-users/zsh-autosuggestions" \ ~/.oh-my-zsh/custom/plugins/zsh-autosuggestions \ && git clone --branch master --single-branch --depth 1 \ "git://github.com/zsh-users/zsh-syntax-highlighting.git" \ ~/.oh-my-zsh/custom/plugins/zsh-syntax-highlighting \ \ && sed -i -e "s#bin/bash#bin/zsh#" /etc/passwd \ \ && update-alternatives \ --install /usr/bin/python python /usr/bin/python3 10 \ \ && pip3 install --no-cache-dir -r /tmp/requirements.txt \ \ && apt-get purge -y --auto-remove \ bsdtar \ build-essential \ python3-dev \ uuid-runtime \ \ && find /usr/local \ \( -type d -a -name test -o -name tests -o -name '__pycache__' \) \ -o \( -type f -a -name '*.pyc' -o -name '*.pyo' \) \ -exec rm -rf '{}' + \ \ && rm -fr \ /tmp/* \ /var/{cache,log}/* \ /var/lib/apt/lists/* # Copy root filesystem COPY rootfs / # Build arguments ARG BUILD_ARCH ARG BUILD_DATE ARG BUILD_DESCRIPTION ARG BUILD_NAME ARG BUILD_REF ARG BUILD_REPOSITORY ARG BUILD_VERSION # Labels LABEL \ io.hass.name="${BUILD_NAME}" \ io.hass.description="${BUILD_DESCRIPTION}" \ io.hass.arch="${BUILD_ARCH}" \ io.hass.type="addon" \ io.hass.version=${BUILD_VERSION} \ maintainer="Franck Nijhof " \ org.opencontainers.image.title="${BUILD_NAME}" \ org.opencontainers.image.description="${BUILD_DESCRIPTION}" \ org.opencontainers.image.vendor="Home Assistant Community Add-ons" \ org.opencontainers.image.authors="Franck Nijhof " \ org.opencontainers.image.licenses="MIT" \ org.opencontainers.image.url="https://addons.community" \ org.opencontainers.image.source="https://github.com/${BUILD_REPOSITORY}" \ org.opencontainers.image.documentation="https://github.com/${BUILD_REPOSITORY}/blob/main/README.md" \ org.opencontainers.image.created=${BUILD_DATE} \ org.opencontainers.image.revision=${BUILD_REF} \ org.opencontainers.image.version=${BUILD_VERSION}