From 2726dd2cebb3d583ac0d84202a8d9f5fb53bbd60 Mon Sep 17 00:00:00 2001 From: wserr Date: Sat, 7 Jun 2025 22:17:08 +0200 Subject: [PATCH] Updates --- home-server/.env | 2 +- home-server/docker-compose.yml | 9 ++--- .../home-assistant/home-assistant.Dockerfile | 3 ++ .../homeassistant-backup.service | 14 ++++++++ .../homeassistant-backup.timer | 11 ++++++ .../homeassistant-backup/.gitignore | 34 +++++++++++++++++++ .../homeassistant-backup/README.md | 15 ++++++++ .../homeassistant-backup/bun.lock | 25 ++++++++++++++ .../homeassistant-backup/index.ts | 1 + .../homeassistant-backup/package.json | 12 +++++++ .../homeassistant-backup/tsconfig.json | 29 ++++++++++++++++ 11 files changed, 150 insertions(+), 5 deletions(-) create mode 100644 home-server/home-assistant/home-assistant.Dockerfile create mode 100644 home-server/homeassistant-backup/homeassistant-backup.service create mode 100644 home-server/homeassistant-backup/homeassistant-backup.timer create mode 100644 home-server/homeassistant-backup/homeassistant-backup/.gitignore create mode 100644 home-server/homeassistant-backup/homeassistant-backup/README.md create mode 100644 home-server/homeassistant-backup/homeassistant-backup/bun.lock create mode 100644 home-server/homeassistant-backup/homeassistant-backup/index.ts create mode 100644 home-server/homeassistant-backup/homeassistant-backup/package.json create mode 100644 home-server/homeassistant-backup/homeassistant-backup/tsconfig.json diff --git a/home-server/.env b/home-server/.env index fb5b057..5d6f0ce 100644 --- a/home-server/.env +++ b/home-server/.env @@ -1,4 +1,4 @@ -REPO_DIR=/home/pi/repos/homeAutomation +REPO_DIR=/home/willem/repos/homeAutomation # Make sure docker user has read/write access on this folder STORAGE_DIR=/etc diff --git a/home-server/docker-compose.yml b/home-server/docker-compose.yml index bf2015d..6643ea6 100644 --- a/home-server/docker-compose.yml +++ b/home-server/docker-compose.yml @@ -6,8 +6,8 @@ services: - traefik.http.routers.dashboard.rule=Host(`traefik.pladijs`) - traefik.http.services.dashboard.loadbalancer.server.port=8080 volumes: - - ${REPO_DIR}/configurations/traefik/traefik.yml:/etc/traefik/traefik.yml - - ${STORAGE_DIR}/certificates:/var/lib/certificates + - ${REPO_DIR}/configurations/traefik/traefik.yml:/etc/traefik/traefik.yml:ro + - ${STORAGE_DIR}/traefik/certificates:/var/lib/certificates - /var/run/docker.sock:/var/run/docker.sock ports: - 80:80 @@ -31,13 +31,14 @@ services: volumes: - ${STORAGE_DIR}/mariadb:/var/lib/mysql homeassistant: - image: "ghcr.io/home-assistant/home-assistant:stable" + build: + context: ./home-assistant + dockerfile: home-assistant.Dockerfile labels: - traefik.http.routers.homeassistant.rule=Host(`homeassistant.pladijs`) - traefik.http.services.homeassistant.loadbalancer.server.port=8123 volumes: - ${STORAGE_DIR}/homeassistant:/config - - ${REPO_DIR}/configurations/home-assistant/configuration-production.yaml:/config/configuration.yaml restart: unless-stopped env_file: - environment-variables/local.env diff --git a/home-server/home-assistant/home-assistant.Dockerfile b/home-server/home-assistant/home-assistant.Dockerfile new file mode 100644 index 0000000..bcbdc48 --- /dev/null +++ b/home-server/home-assistant/home-assistant.Dockerfile @@ -0,0 +1,3 @@ +FROM ghcr.io/home-assistant/home-assistant:stable + +COPY ./configuration/configuration-production.yaml /config/configuration.yaml diff --git a/home-server/homeassistant-backup/homeassistant-backup.service b/home-server/homeassistant-backup/homeassistant-backup.service new file mode 100644 index 0000000..81fba3b --- /dev/null +++ b/home-server/homeassistant-backup/homeassistant-backup.service @@ -0,0 +1,14 @@ +[Unit] +Description=Backup Home Assistant +After=network.target + +[Service] +ExecStart=/home/willem/.bun/bin/bun /home/willem/repos/homeAutomation/home-server/homeassistant-backup/homeassistant-backup/index.ts +WorkingDirectory=/home/willem/repos/homeAutomation/home-server/homeassistant-backup/homeassistant-backup +Restart=on-failure +User=willem +Environment=PATH=/usr/bin:/usr/local/bin +Environment=NODE_ENV=production + +[Install] +WantedBy=multi-user.target diff --git a/home-server/homeassistant-backup/homeassistant-backup.timer b/home-server/homeassistant-backup/homeassistant-backup.timer new file mode 100644 index 0000000..65fcb96 --- /dev/null +++ b/home-server/homeassistant-backup/homeassistant-backup.timer @@ -0,0 +1,11 @@ +[Unit] +Description=Run Home assistant backup Service every hour + +[Timer] +OnBootSec=1min +OnUnitActiveSec=1hour +Persistent=true + +[Install] +WantedBy=timers.target + diff --git a/home-server/homeassistant-backup/homeassistant-backup/.gitignore b/home-server/homeassistant-backup/homeassistant-backup/.gitignore new file mode 100644 index 0000000..a14702c --- /dev/null +++ b/home-server/homeassistant-backup/homeassistant-backup/.gitignore @@ -0,0 +1,34 @@ +# dependencies (bun install) +node_modules + +# output +out +dist +*.tgz + +# code coverage +coverage +*.lcov + +# logs +logs +_.log +report.[0-9]_.[0-9]_.[0-9]_.[0-9]_.json + +# dotenv environment variable files +.env +.env.development.local +.env.test.local +.env.production.local +.env.local + +# caches +.eslintcache +.cache +*.tsbuildinfo + +# IntelliJ based IDEs +.idea + +# Finder (MacOS) folder config +.DS_Store diff --git a/home-server/homeassistant-backup/homeassistant-backup/README.md b/home-server/homeassistant-backup/homeassistant-backup/README.md new file mode 100644 index 0000000..94e71d1 --- /dev/null +++ b/home-server/homeassistant-backup/homeassistant-backup/README.md @@ -0,0 +1,15 @@ +# homeassistant-backup + +To install dependencies: + +```bash +bun install +``` + +To run: + +```bash +bun run index.ts +``` + +This project was created using `bun init` in bun v1.2.15. [Bun](https://bun.sh) is a fast all-in-one JavaScript runtime. diff --git a/home-server/homeassistant-backup/homeassistant-backup/bun.lock b/home-server/homeassistant-backup/homeassistant-backup/bun.lock new file mode 100644 index 0000000..cf1c25c --- /dev/null +++ b/home-server/homeassistant-backup/homeassistant-backup/bun.lock @@ -0,0 +1,25 @@ +{ + "lockfileVersion": 1, + "workspaces": { + "": { + "name": "homeassistant-backup", + "devDependencies": { + "@types/bun": "latest", + }, + "peerDependencies": { + "typescript": "^5", + }, + }, + }, + "packages": { + "@types/bun": ["@types/bun@1.2.15", "", { "dependencies": { "bun-types": "1.2.15" } }, "sha512-U1ljPdBEphF0nw1MIk0hI7kPg7dFdPyM7EenHsp6W5loNHl7zqy6JQf/RKCgnUn2KDzUpkBwHPnEJEjII594bA=="], + + "@types/node": ["@types/node@22.15.30", "", { "dependencies": { "undici-types": "~6.21.0" } }, "sha512-6Q7lr06bEHdlfplU6YRbgG1SFBdlsfNC4/lX+SkhiTs0cpJkOElmWls8PxDFv4yY/xKb8Y6SO0OmSX4wgqTZbA=="], + + "bun-types": ["bun-types@1.2.15", "", { "dependencies": { "@types/node": "*" } }, "sha512-NarRIaS+iOaQU1JPfyKhZm4AsUOrwUOqRNHY0XxI8GI8jYxiLXLcdjYMG9UKS+fwWasc1uw1htV9AX24dD+p4w=="], + + "typescript": ["typescript@5.8.3", "", { "bin": { "tsc": "bin/tsc", "tsserver": "bin/tsserver" } }, "sha512-p1diW6TqL9L07nNxvRMM7hMMw4c5XOo/1ibL4aAIGmSAt9slTE1Xgw5KWuof2uTOvCg9BY7ZRi+GaF+7sfgPeQ=="], + + "undici-types": ["undici-types@6.21.0", "", {}, "sha512-iwDZqg0QAGrg9Rav5H4n0M64c3mkR59cJ6wQp+7C4nI0gsmExaedaYLNO44eT4AtBBwjbTiGPMlt2Md0T9H9JQ=="], + } +} diff --git a/home-server/homeassistant-backup/homeassistant-backup/index.ts b/home-server/homeassistant-backup/homeassistant-backup/index.ts new file mode 100644 index 0000000..f67b2c6 --- /dev/null +++ b/home-server/homeassistant-backup/homeassistant-backup/index.ts @@ -0,0 +1 @@ +console.log("Hello via Bun!"); \ No newline at end of file diff --git a/home-server/homeassistant-backup/homeassistant-backup/package.json b/home-server/homeassistant-backup/homeassistant-backup/package.json new file mode 100644 index 0000000..d20b646 --- /dev/null +++ b/home-server/homeassistant-backup/homeassistant-backup/package.json @@ -0,0 +1,12 @@ +{ + "name": "homeassistant-backup", + "module": "index.ts", + "type": "module", + "private": true, + "devDependencies": { + "@types/bun": "latest" + }, + "peerDependencies": { + "typescript": "^5" + } +} diff --git a/home-server/homeassistant-backup/homeassistant-backup/tsconfig.json b/home-server/homeassistant-backup/homeassistant-backup/tsconfig.json new file mode 100644 index 0000000..bfa0fea --- /dev/null +++ b/home-server/homeassistant-backup/homeassistant-backup/tsconfig.json @@ -0,0 +1,29 @@ +{ + "compilerOptions": { + // Environment setup & latest features + "lib": ["ESNext"], + "target": "ESNext", + "module": "Preserve", + "moduleDetection": "force", + "jsx": "react-jsx", + "allowJs": true, + + // Bundler mode + "moduleResolution": "bundler", + "allowImportingTsExtensions": true, + "verbatimModuleSyntax": true, + "noEmit": true, + + // Best practices + "strict": true, + "skipLibCheck": true, + "noFallthroughCasesInSwitch": true, + "noUncheckedIndexedAccess": true, + "noImplicitOverride": true, + + // Some stricter flags (disabled by default) + "noUnusedLocals": false, + "noUnusedParameters": false, + "noPropertyAccessFromIndexSignature": false + } +}