Skip to content

Commit

Permalink
ps5-mqtt usage
Browse files Browse the repository at this point in the history
  • Loading branch information
andrew-codes committed Nov 8, 2024
1 parent 2acf964 commit 1051719
Show file tree
Hide file tree
Showing 20 changed files with 14 additions and 786 deletions.
6 changes: 0 additions & 6 deletions apps/ps5/.dockerignore

This file was deleted.

1 change: 0 additions & 1 deletion apps/ps5/.gitignore

This file was deleted.

10 changes: 0 additions & 10 deletions apps/ps5/Dockerfile

This file was deleted.

13 changes: 11 additions & 2 deletions apps/ps5/deployment/index.jsonnet
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,23 @@ local k = import 'github.com/jsonnet-libs/k8s-libsonnet/1.29/main.libsonnet';

local deployment = lib.deployment.new(std.extVar('name'), std.extVar('image'), std.extVar('secrets'), '', '8080')
+ lib.deployment.withEnvVars(0, [
{ name: 'NODE_ENV', value: 'production' },
{ name: 'MQTT_HOST', value: 'mqtt' },
{ name: 'MQTT_PORT', value: '1883' },
{ name: 'DEVICE_CHECK_INTERVAL', value: '5000' },
{ name: 'DEVICE_DISCOVERY_INTERVAL', value: '60000' },
{ name: 'ACCOUNT_CHECK_INTERVAL', value: '5000' },
{ name: 'FRONTEND_PORT', value: '8645' },
{ name: 'CREDENTIAL_STORAGE_PATH', value: '/config/credentials.json' },
{ name: 'DEBUG', value: '@ha:ps5:*' },
])
+ lib.deployment.withContainerAugmentation(0, {
command: ['sh'],
args: ['-c', '/app/run-standalone.sh'],
})
+ lib.deployment.withHostNetwork()
+ lib.deployment.withInitContainer('mqtt-is-ready', std.extVar('registryHostname') + '/mqtt-client:latest', { env: [secrets['mqtt/username'], secrets['mqtt/password']], command: ['sh'], args: ['-c', 'timeout 10 sub -h mqtt -t "\\$SYS/#" -C 1 -u $MQTT_USERNAME -P $MQTT_PASSWORD | grep -v Error || exit 1'] })
+ lib.deployment.withInitContainer('home-assistant-is-ready', 'curlimages/curl:latest', { command: ['sh'], args: ['-c', "timeout 10 curl --fail --insecure --silent --output /dev/null --write-out 'HTTP Code %{http_code}' 'https://ha.smith-simms.family' || exit 1"] })
+ lib.deployment.withVolumeMount(0, k.core.v1.volumeMount.new('ps5-credentials', '/root/.config/playactor',))
+ lib.deployment.withVolumeMount(0, k.core.v1.volumeMount.new('ps5-credentials', '/config/credentials.json',))
+ lib.deployment.withSecretVolume('ps5-credentials', 'ps5-credentials-json', 511, [{ key: 'secret-value', path: 'credentials.json' }])
;

Expand Down
3 changes: 0 additions & 3 deletions apps/ps5/jest.config.js

This file was deleted.

9 changes: 0 additions & 9 deletions apps/ps5/nodemon.json

This file was deleted.

52 changes: 0 additions & 52 deletions apps/ps5/project.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,64 +4,12 @@
"sourceRoot": "apps/ps5/src",
"projectType": "application",
"targets": {
"clean": {
"executor": "@nrwl/workspace:run-commands",
"outputs": ["{projectRoot}/dist", "{projectRoot}/.test-runs"],
"options": {
"command": "rm -rf dist .test-runs",
"cwd": "apps/ps5"
}
},
"compile": {
"executor": "@ha/nx-executors:invoke",
"outputs": ["{projectRoot}/dist"],
"options": {
"module": "scripts/compile.ts",
"cwd": "apps/ps5"
}
},
"deploy": {
"executor": "@ha/nx-executors:invoke",
"options": {
"cwd": "apps/ps5",
"module": "scripts/deploy.ts"
}
},
"image/push": {
"executor": "@ha/nx-executors:invoke",
"dependsOn": [
{
"target": "compile",
"projects": "self"
}
],
"options": {
"module": "scripts/image-push.ts",
"cwd": "apps/ps5"
}
},
"test": {
"executor": "@nrwl/workspace:run-commands",
"outputs": ["{projectRoot}/.test-runs/unit"],
"options": {
"command": "jest",
"cwd": "apps/ps5"
}
},
"code-coverage": {
"executor": "@ha/nx-executors:upload-codecov",
"options": {
"coverageFilePath": "apps/ps5/.test-runs/unit/lcov.info"
}
},
"serve": {
"executor": "@ha/nx-executors:telepresence-local",
"options": {
"command": "yarn nodemon src/index.ts --inspect=0.0.0.0:9233",
"cwd": "apps/ps5",
"fromPort": 8086,
"toPort": 80
}
}
},
"tags": [],
Expand Down
6 changes: 3 additions & 3 deletions apps/ps5/scripts/deploy.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import path from "path"
import sh from "shelljs"
import type { ConfigurationApi } from "@ha/configuration-api"
import type { Configuration } from "@ha/configuration-workspace"
import { jsonnet } from "@ha/jsonnet"
import { kubectl } from "@ha/kubectl"
import path from "path"
import sh from "shelljs"
import { name } from "./config"

const run = async (
Expand All @@ -14,7 +14,7 @@ const run = async (
const resources = await jsonnet.eval(
path.join(__dirname, "..", "deployment", "index.jsonnet"),
{
image: `${registry.value}/${name}:latest`,
image: `ghcr.io/funkeyflo/ps5-mqtt/amd64:latest`,
name,
registryHostname: registry.value,
secrets,
Expand Down
71 changes: 0 additions & 71 deletions apps/ps5/src/index.ts

This file was deleted.

99 changes: 0 additions & 99 deletions apps/ps5/src/state/device.slice.ts

This file was deleted.

28 changes: 0 additions & 28 deletions apps/ps5/src/state/index.ts

This file was deleted.

45 changes: 0 additions & 45 deletions apps/ps5/src/state/polling.slice.ts

This file was deleted.

Loading

0 comments on commit 1051719

Please sign in to comment.