From 96f63f4c3ea5596b07e763d2f698ba9f1816bccd Mon Sep 17 00:00:00 2001 From: Michael Hollister Date: Wed, 7 May 2025 18:12:38 -0500 Subject: [PATCH] webOS: Added Docker container for local development --- receivers/webos/.gitignore | 1 + receivers/webos/.gitlab-ci.yml | 10 ++--- receivers/webos/Dockerfile | 12 +++++ receivers/webos/README.md | 51 ++++++++++++---------- receivers/webos/scripts/build.sh | 9 ++++ receivers/webos/scripts/debug.sh | 9 ++++ receivers/webos/scripts/get_private_key.sh | 9 ++++ 7 files changed, 72 insertions(+), 29 deletions(-) create mode 100644 receivers/webos/Dockerfile create mode 100755 receivers/webos/scripts/build.sh create mode 100755 receivers/webos/scripts/debug.sh create mode 100755 receivers/webos/scripts/get_private_key.sh diff --git a/receivers/webos/.gitignore b/receivers/webos/.gitignore index 5ce66af..2796993 100644 --- a/receivers/webos/.gitignore +++ b/receivers/webos/.gitignore @@ -1,4 +1,5 @@ fcast-receiver/dist fcast-receiver-service/dist +.env *.ipk diff --git a/receivers/webos/.gitlab-ci.yml b/receivers/webos/.gitlab-ci.yml index d19e4fc..2299b1b 100644 --- a/receivers/webos/.gitlab-ci.yml +++ b/receivers/webos/.gitlab-ci.yml @@ -1,21 +1,19 @@ buildWebOS: stage: buildWebOSReceiver - image: node:22.11.0-bookworm + image: node:16.20.2-bullseye tags: - fcast-instance-runner before_script: - cd receivers/webos - npm install -g @webos-tools/cli - script: - cd fcast-receiver - npm install - - npm run build - cd ../fcast-receiver-service - npm install - - npm run build - - cd ../ - - ares-package fcast-receiver/dist/ fcast-receiver-service/dist/ --no-minify + - cd .. + script: + - scripts/build.sh artifacts: untracked: false when: on_success diff --git a/receivers/webos/Dockerfile b/receivers/webos/Dockerfile new file mode 100644 index 0000000..2bbbc85 --- /dev/null +++ b/receivers/webos/Dockerfile @@ -0,0 +1,12 @@ +FROM node:16.20.2-bullseye + +ARG TV_IP +ARG PASSPHRASE + +RUN apt update && apt install -y expect jq + +RUN npm install -g @webos-tools/cli +RUN ares-setup-device --add tv --info "host=${TV_IP}" --info "default=true" + +COPY scripts/get_private_key.sh . +RUN ./get_private_key.sh ares-novacom --device tv --getkey diff --git a/receivers/webos/README.md b/receivers/webos/README.md index a22e171..db043ed 100644 --- a/receivers/webos/README.md +++ b/receivers/webos/README.md @@ -6,33 +6,38 @@ The TV receiver player is a simplified player compared to the Electron receiver # How to build -From `receivers/webos` directory: +## Preparing for build -## Prerequisites -```sh -npm install -g @webos-tools/cli -cd fcast-receiver -npm install -cd ../fcast-receiver-service -npm install -cd ../ +A docker file is provided to setup your build and debug environment for a local TV device. From the root of the repository: + +### Build +```bash +source receivers/webos/.env && docker build -t fcast/receiver-webos-dev:latest \ + --build-arg TV_IP=$TV_IP --build-arg PASSPHRASE=$PASSPHRASE receivers/webos/ ``` -## Build -```sh -cd fcast-receiver -npm run build -cd ../fcast-receiver-service -npm run build -cd ../ +Note that you must have the key server enabled during the build process. + +To populate the container build arguments, you must export the following environment variables or set them in your `.env` file in `receivers/webos/.env`: +``` +TV_IP=YOUR_TV_IP_ADDRESS +PASSPHRASE=YOUR_TV_PASSPHRASE ``` -## Packaging -```sh -ares-package fcast-receiver/dist/ fcast-receiver-service/dist/ --no-minify +This information is found in the development app. + +### Run +```bash +docker run --rm -it -w /app/receivers/webos --entrypoint='bash' --network host \ + -v .:/app fcast/receiver-webos-dev:latest ``` -## Debugging -* Install: `ares-install --device tv ./com.futo.fcast.receiver_1.0.0_all.ipk` -* Web app debug: `ares-inspect --device tv --app com.futo.fcast.receiver -o` -* Service debug: `ares-inspect --device tv -s com.futo.fcast.receiver.service` +Note that you must enable host networking support in your docker engine. Also, the production application +from the LG store must be uninstalled in order to run and debug the development version. + +## Commands + +* Build app: `scripts/build.sh` +* Debug app: `scripts/debug.sh` + +Build artifact .ipk will be located in `receivers/webos` diff --git a/receivers/webos/scripts/build.sh b/receivers/webos/scripts/build.sh new file mode 100755 index 0000000..2dc4a34 --- /dev/null +++ b/receivers/webos/scripts/build.sh @@ -0,0 +1,9 @@ +#!/bin/bash + +cd fcast-receiver +npm run build +cd ../fcast-receiver-service +npm run build +cd ../ + +ares-package fcast-receiver/dist/ fcast-receiver-service/dist/ --no-minify diff --git a/receivers/webos/scripts/debug.sh b/receivers/webos/scripts/debug.sh new file mode 100755 index 0000000..06a1f2f --- /dev/null +++ b/receivers/webos/scripts/debug.sh @@ -0,0 +1,9 @@ +#!/bin/bash + +version=$(jq -r '.version' fcast-receiver/package.json) +scripts/build.sh +ares-install --device tv ./com.futo.fcast.receiver_${version}_all.ipk + +ares-inspect --device tv -s com.futo.fcast.receiver.service & +sleep 5 +ares-inspect --device tv --app com.futo.fcast.receiver diff --git a/receivers/webos/scripts/get_private_key.sh b/receivers/webos/scripts/get_private_key.sh new file mode 100755 index 0000000..c939c2a --- /dev/null +++ b/receivers/webos/scripts/get_private_key.sh @@ -0,0 +1,9 @@ +#!/usr/bin/expect -f + +set timeout -1 +spawn {*}$argv + +expect "SSH Private Key: /root/.ssh/tv_webos" +send -- "$env(PASSPHRASE)\n" + +expect eof