-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile
89 lines (79 loc) · 3.73 KB
/
Dockerfile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
# [Choice] Python version (use -bullseye variants on local arm64/Apple Silicon): 3, 3.10, 3.9, 3.8, 3.7, 3.6, 3-bullseye, 3.10-bullseye, 3.9-bullseye, 3.8-bullseye, 3.7-bullseye, 3.6-bullseye, 3-buster, 3.10-buster, 3.9-buster, 3.8-buster, 3.7-buster, 3.6-buster
ARG VARIANT="3.10-bullseye"
FROM mcr.microsoft.com/vscode/devcontainers/python:0-${VARIANT} as build
# [Choice] Node.js version: none, lts/*, 16, 14, 12, 10
ARG NODE_VERSION="none"
RUN if [ "${NODE_VERSION}" != "none" ]; then su vscode -c "umask 0002 && . /usr/local/share/nvm/nvm.sh && nvm install ${NODE_VERSION} 2>&1"; fi
# run as root from now on
USER root
# Environment Variable defaults
ENV DEVCONTAINER=True
ENV DEBIAN_FRONTEND=noninteractive
ENV ZSH=~/.oh-my-zsh
# open ports
## hass
EXPOSE 8123
## python remote debugger
EXPOSE 5678
WORKDIR /tmp
# install ZSH Shell
RUN \
wget https://raw.github.com/robbyrussell/oh-my-zsh/master/tools/install.sh -O oh-my-zsh-install.sh \
&& rm -rf /root/.oh-my-zsh \
&& chmod +x ./oh-my-zsh-install.sh \
&& sudo ./oh-my-zsh-install.sh --unattended \
&& rm -f ./oh-my-zsh-install.sh
# deploy ha-devcontainer commands, scripts, home assistant basic config, default shell, ...
COPY copy_root/ /
#*1) prepare source to copy from for home-assistant/core
RUN git clone https://github.com/home-assistant/core.git
# Add Home Assistant wheels repository
ENV WHEELS_LINKS=https://wheels.home-assistant.io/musllinux/
#*1 from here on, COPY RELATIVE_PATH should get: RUN cp -rf /tmp/core/RELATIVE_PATH
# used for https://github.com/home-assistant/core/blob/dev/Dockerfile below
WORKDIR /usr/src
#*2 removed this from all pip install commands (without single quotes):
# ' --no-cache-dir --no-index --only-binary=:all: --find-links "${WHEELS_LINKS}"''
#*3 removed ' home_assistant_frontend-*' from the COPY, as the folder/file is not existant in core git.
##### START dependencies from https://github.com/home-assistant/core/blob/dev/Dockerfile
# Synchronize with homeassistant/core.py:async_stop
ENV \
S6_SERVICES_GRACETIME=220000
RUN \
#install 'dev' cli \
cd /opt/dev \
&& pip install --editable . \
# install build tools and libs
&& apt-get update \
&& apt-get -y install --no-install-recommends bluez build-essential cmake libpcap-dev \
# Setup Home Assistant Core and dependencies \
&& mkdir -p homeassistant/homeassistant \
&& cp -rf /tmp/core/requirements.txt homeassistant/ \
&& cp -rf /tmp/core/homeassistant/package_constraints.txt homeassistant/homeassistant/ \
&& pip3 install \
-r homeassistant/requirements.txt --use-deprecated=legacy-resolver \
&& cp -rf /tmp/core/requirements_all.txt homeassistant/ \
&& if ls homeassistant/home_assistant_frontend*.whl 1> /dev/null 2>&1; then \
pip3 install --no-cache-dir --no-index homeassistant/home_assistant_frontend-*.whl; \
fi \
&& pip3 install \
-r homeassistant/requirements_all.txt --use-deprecated=legacy-resolver \
&& cp -rf /tmp/core/. homeassistant/ \
&& cp -rf /tmp/core/rootfs / \
&& pip3 install \
-e ./homeassistant --use-deprecated=legacy-resolver \
&& python3 -m compileall homeassistant/homeassistant \
#prepare hacs \
&& cd /config \
&& mkdir -p /config/custom_components \
&& wget https://get.hacs.xyz -O hacs-install.sh \
&& chmod +x ./hacs-install.sh \
&& ./hacs-install.sh \
&& rm -f ./hacs-install.sh \
#run and Stop home assistant when onboading dialog is shown \
&& /usr/local/bin/dev ha start --install-deps-only \
#cleanup \
&& apt-get clean \
&& rm -fr /var/lib/apt/lists/* \
&& 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}/* /root/.cache