From 94e4f454bcab82d2617f3c419e11ded69118ce7d Mon Sep 17 00:00:00 2001 From: RoboMagus <68224306+RoboMagus@users.noreply.github.com> Date: Wed, 9 Aug 2023 14:29:24 +0200 Subject: [PATCH] Add devcontainer + base config --- .devcontainer/config/configuration.yaml | 34 +++++++++++++++++++++ .devcontainer/devcontainer.json | 39 +++++++++++++++++++++++++ .devcontainer/scripts/run | 6 ++++ .devcontainer/scripts/setup | 10 +++++++ .gitignore | 10 +++++++ 5 files changed, 99 insertions(+) create mode 100644 .devcontainer/config/configuration.yaml create mode 100644 .devcontainer/devcontainer.json create mode 100644 .devcontainer/scripts/run create mode 100644 .devcontainer/scripts/setup create mode 100644 .gitignore diff --git a/.devcontainer/config/configuration.yaml b/.devcontainer/config/configuration.yaml new file mode 100644 index 0000000..76a0ff6 --- /dev/null +++ b/.devcontainer/config/configuration.yaml @@ -0,0 +1,34 @@ +homeassistant: + name: development + unit_system: metric + temperature_unit: C + country: NL + time_zone: Europe/Amsterdam + latitude: 52.377956 + longitude: 4.897070 + elevation: 0 + +default_config: + +logger: + default: info + logs: + custom_components.monitor_docker: debug +# If you need to debug uncommment the line below (doc: https://www.home-assistant.io/integrations/debugpy/) +# debugpy: + +monitor_docker: + - name: Docker + scan_interval: 30 + monitored_conditions: + - containers_running + - containers_total + - containers_1cpu_percentage + - containers_memory + - containers_memory_percentage + - state + - status + - uptime + - 1cpu_percentage + - memory + switchenabled: false diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json new file mode 100644 index 0000000..27b9489 --- /dev/null +++ b/.devcontainer/devcontainer.json @@ -0,0 +1,39 @@ +// See https://aka.ms/vscode-remote/devcontainer.json for format details. +{ + "image": "mcr.microsoft.com/vscode/devcontainers/python:0-3.11-bullseye", + "name": "HACS Monitor_Docker integration development", + "appPort": [ + "9123:8123" + ], + "mounts": [ + "source=/var/run/docker.sock,target=/var/run/docker.sock,type=bind", + "source=${localWorkspaceFolder}/.devcontainer/config,target=/config,type=bind", + "source=${localWorkspaceFolder}/custom_components/monitor_docker,target=/config/custom_components/monitor_docker,type=bind" + ], + "postCreateCommand": "bash .devcontainer/scripts/setup", + "postStartCommand": "bash .devcontainer/scripts/run", + "extensions": [ + "ms-python.python", + "github.vscode-pull-request-github", + "ryanluker.vscode-coverage-gutters", + "ms-python.vscode-pylance" + ], + "settings": { + "files.eol": "\n", + "editor.tabSize": 4, + "terminal.integrated.shell.linux": "/bin/bash", + "python.pythonPath": "/usr/bin/python3", + "python.analysis.autoSearchPaths": false, + "python.linting.pylintEnabled": true, + "python.linting.enabled": true, + "python.formatting.provider": "black", + "editor.formatOnPaste": false, + "editor.formatOnSave": true, + "editor.formatOnType": true, + "files.trimTrailingWhitespace": true + }, + "remoteUser": "root", + "features": { + "rust": "latest" + } +} \ No newline at end of file diff --git a/.devcontainer/scripts/run b/.devcontainer/scripts/run new file mode 100644 index 0000000..b55608e --- /dev/null +++ b/.devcontainer/scripts/run @@ -0,0 +1,6 @@ +#!/usr/bin/env bash + +set -e + +# Start Home Assistant +hass -c /config \ No newline at end of file diff --git a/.devcontainer/scripts/setup b/.devcontainer/scripts/setup new file mode 100644 index 0000000..74bd5dd --- /dev/null +++ b/.devcontainer/scripts/setup @@ -0,0 +1,10 @@ +#!/usr/bin/env bash + +set -e + +# Install HomeAssistant latest release +# Setup base user with 'dev' UN & PWD + +python3 -m pip install colorlog && \ +python3 -m pip install homeassistant && \ +hass --script auth add dev dev diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..14b0735 --- /dev/null +++ b/.gitignore @@ -0,0 +1,10 @@ + +# Python generated files +__pycache__/ +*.py[cod] + +# Ignore auto generated HA Files in devcontainer config: +.devcontainer/config/.*/ +.devcontainer/config/*.db* +.devcontainer/config/*.log* +.devcontainer/config/.HA_VERSION