Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add devcontainer + base config #130

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 34 additions & 0 deletions .devcontainer/config/configuration.yaml
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Might have to add at least parts of below snippet for GitHub Code Space to allow port forwards.

http:
  use_x_forwarded_for: true
  trusted_proxies:
    - 127.0.0.1
    - ::1

Original file line number Diff line number Diff line change
@@ -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
39 changes: 39 additions & 0 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -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"
}
}
6 changes: 6 additions & 0 deletions .devcontainer/scripts/run
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#!/usr/bin/env bash

set -e

# Start Home Assistant
hass -c /config
Copy link

@dala318 dala318 Jan 15, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

.devcontainer/config ?

10 changes: 10 additions & 0 deletions .devcontainer/scripts/setup
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would help if you make the scripts executable by default chmod +x .devcontainer/scripts/* and commit the new "mode 100755"

Original file line number Diff line number Diff line change
@@ -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
10 changes: 10 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -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