Skip to content

Commit

Permalink
build(devcontainer): add devcontainer configuraion
Browse files Browse the repository at this point in the history
  • Loading branch information
joshuar committed Jun 15, 2023
1 parent 576b2ff commit 0bcbd69
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 0 deletions.
20 changes: 20 additions & 0 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"image": "mcr.microsoft.com/devcontainers/python",
"appPort": ["8123:8123"],
"postCreateCommand": "tools/devcontainer/postcreate",
"postStartCommand": ". /workspaces/go-hass-agent/home-assistant/venv/bin/activate && hass -c $HA_PATH/config",
"remoteEnv": {
"PATH": "${containerEnv:PATH}:/usr/local/go/bin",
"GO_DL": "go1.20.5.linux-amd64.tar.gz",
"HA_PATH": "/workspaces/go-hass-agent/home-assistant",
"DISPLAY": "${localEnv:DISPLAY}"
},
"mounts": [
"source=/tmp/.X11-unix,target=/tmp/.X11-unix,type=bind,consistency=cached"
],
"runArgs": [
"--userns=keep-id:uid=1000,gid=1000"
],
"containerUser": "vscode",
"updateRemoteUserUID": true
}
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# Ignore everything
.vscode/
internal/agent/VERSION
home-assistant

# But not these files...
!.gitignore
Expand Down
27 changes: 27 additions & 0 deletions tools/devcontainer/postcreate
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#!/usr/bin/env bash

# Copyright (c) 2023 Joshua Rich <[email protected]>
#
# This software is released under the MIT License.
# https://opensource.org/licenses/MIT

# Stop on errors
set -e

# Install Home Assistant

sudo apt-get update
sudo apt-get install -y python3-pip python3-dev python3-venv autoconf libssl-dev libxml2-dev libxslt1-dev libjpeg-dev libffi-dev libudev-dev zlib1g-dev pkg-config libavformat-dev libavcodec-dev libavdevice-dev libavutil-dev libswscale-dev libavresample-dev libavfilter-dev ffmpeg
rm -rf ${HA_PATH} && git clone https://github.com/home-assistant/core.git ${HA_PATH}
cd ${HA_PATH}
script/setup

# Install Go

curl -L -o /tmp/${GO_DL} https://go.dev/dl/${GO_DL}
sudo rm -rf /usr/local/go && sudo tar -C /usr/local -xzf /tmp/${GO_DL}

# Install go-hass-agent dependencies

sudo apt-get -y install libgl1-mesa-dev libxi-dev libxcursor-dev libxrandr-dev libxinerama-dev libxxf86vm-dev dbus-x11
cd /workspaces/go-hass-agent && go mod download

0 comments on commit 0bcbd69

Please sign in to comment.