ARG BUILD_FROM=ghcr.io/hassio-addons/debian-base:7.8.2 # hadolint ignore=DL3006 FROM ${BUILD_FROM} # Confiure locale ENV \ LANG=en_US.UTF-8 \ LANGUAGE=en_US:en \ LC_ALL=en_US.UTF-8 \ PIP_BREAK_SYSTEM_PACKAGES=1 # 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 ARG CODE_SERVER_VERSION="v4.99.2" ARG HA_CLI_VERSION="4.37.0" # hadolint ignore=SC2181, DL3008 RUN \ apt-get update \ \ && apt-get install -y --no-install-recommends \ ack=3.6.0-1 \ libarchive-tools=3.6.2-1+deb12u2 \ build-essential=12.9 \ colordiff=1.0.20-1 \ git=1:2.39.5-0+deb12u2 \ iputils-ping=3:20221126-1+deb12u1 \ locales=2.36-9+deb12u7 \ mariadb-client=1:10.11.11-0+deb12u1 \ mosquitto-clients=2.0.11-1.2+deb12u1 \ net-tools=2.10-0.1 \ nmap=7.93+dfsg1-1 \ openssh-client=1:9.2p1-2+deb12u5 \ openssl=3.0.15-1~deb12u1 \ python3-dev=3.11.2-1+b1 \ python3=3.11.2-1+b1 \ unzip=6.0-28 \ uuid-runtime=2.38.1-5+deb12u1 \ wget>=1.21.3-1+b2 \ zip=3.0-13 \ zsh=5.9-4+b5 \ less=590-2.1~deb12u2 \ \ && 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/coder/code-server/releases/download/${CODE_SERVER_VERSION}/code-server-${CODE_SERVER_VERSION#v}-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 \ \ && 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 "/usr/local/lib/code-server/lib/vscode/extensions/${extention}-${version}"; \ bsdtar --strip-components=1 -xf "/tmp/${extention}-${version}.vsix" \ -C "/usr/local/lib/code-server/lib/vscode/extensions/${extention}-${version}" extension; \ [ $? -ne 0 ] && exit 1; \ sleep 1; \ done < /root/vscode.extensions \ && ls -la /usr/local/lib/code-server/lib/vscode/extensions/ \ \ && curl -L -s -o /usr/bin/ha \ "https://github.com/home-assistant/cli/releases/download/${HA_CLI_VERSION}/ha_${BUILD_ARCH}" \ && chmod a+x /usr/bin/ha \ \ && git clone --branch master --single-branch --depth 1 \ "https://github.com/robbyrussell/oh-my-zsh.git" ~/.oh-my-zsh \ \ && git clone --branch master --single-branch --depth 1 \ "https://github.com/zsh-users/zsh-autosuggestions" \ ~/.oh-my-zsh/custom/plugins/zsh-autosuggestions \ && git clone --branch master --single-branch --depth 1 \ "https://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 \ build-essential \ libarchive-tools \ 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 \ /root/.cache \ /tmp/* \ /var/{cache,log}/* \ /var/lib/apt/lists/* # Copy root filesystem COPY rootfs / # Health check HEALTHCHECK \ CMD curl --fail http://127.0.0.1:1337/healthz || exit 1 # 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}