From d8e17e921610e418e5731a0f12ae2da52551deea Mon Sep 17 00:00:00 2001 From: Koushik Dutta Date: Wed, 5 Nov 2025 10:32:25 -0800 Subject: [PATCH] core: remove watchtower from proxmox totally --- install/proxmox/docker-compose.sh | 1 + plugins/core/package-lock.json | 4 ++-- plugins/core/package.json | 2 +- plugins/core/src/main.ts | 1 - plugins/core/src/platform/lxc.ts | 25 +++++++++++++++++++++++-- 5 files changed, 27 insertions(+), 6 deletions(-) diff --git a/install/proxmox/docker-compose.sh b/install/proxmox/docker-compose.sh index 986a1ec59..4eab4e0c8 100755 --- a/install/proxmox/docker-compose.sh +++ b/install/proxmox/docker-compose.sh @@ -36,4 +36,5 @@ docker compose pull WATCHTOWER_HTTP_API_TOKEN=$(echo $RANDOM | md5sum | head -c 32) docker compose up --force-recreate # abort on container exit is problematic if watchtower is the one that aborts. +# this is also redundant now that watchtower is disabled. # WATCHTOWER_HTTP_API_TOKEN=$(echo $RANDOM | md5sum | head -c 32) docker compose up --force-recreate --abort-on-container-exit diff --git a/plugins/core/package-lock.json b/plugins/core/package-lock.json index d1b41f8cd..b41bb93d2 100644 --- a/plugins/core/package-lock.json +++ b/plugins/core/package-lock.json @@ -1,12 +1,12 @@ { "name": "@scrypted/core", - "version": "0.3.138", + "version": "0.3.139", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "@scrypted/core", - "version": "0.3.138", + "version": "0.3.139", "license": "Apache-2.0", "dependencies": { "@scrypted/common": "file:../../common", diff --git a/plugins/core/package.json b/plugins/core/package.json index 355ade075..428e0f98e 100644 --- a/plugins/core/package.json +++ b/plugins/core/package.json @@ -1,6 +1,6 @@ { "name": "@scrypted/core", - "version": "0.3.138", + "version": "0.3.139", "description": "Scrypted Core plugin. Provides the UI, websocket, and engine.io APIs.", "author": "Scrypted", "license": "Apache-2.0", diff --git a/plugins/core/src/main.ts b/plugins/core/src/main.ts index c601f300b..53066511d 100644 --- a/plugins/core/src/main.ts +++ b/plugins/core/src/main.ts @@ -345,7 +345,6 @@ class ScryptedCore extends ScryptedDeviceBase implements HttpRequestHandler, Dev const dockerCompose = yaml.parseDocument(readFileAsString('/root/.scrypted/docker-compose.yml')); // @ts-ignore dockerCompose.contents.get('services').get('scrypted').set('image', `ghcr.io/koush/scrypted${releaseChannel}`); - yaml.stringify(dockerCompose); writeFileSync('/root/.scrypted/docker-compose.yml', yaml.stringify(dockerCompose)); this.setPullImage(); diff --git a/plugins/core/src/platform/lxc.ts b/plugins/core/src/platform/lxc.ts index 7bd2a729e..9c13aa759 100644 --- a/plugins/core/src/platform/lxc.ts +++ b/plugins/core/src/platform/lxc.ts @@ -1,5 +1,7 @@ -import fs from 'fs'; +import fs, { writeFileSync } from 'fs'; import sdk from '@scrypted/sdk'; +import yaml from 'yaml'; +import { readFileAsString } from '@scrypted/common/src/eval/scrypted-eval'; export const SCRYPTED_INSTALL_ENVIRONMENT_LXC = 'lxc'; export const SCRYPTED_INSTALL_ENVIRONMENT_LXC_DOCKER = 'lxc-docker'; @@ -18,6 +20,25 @@ export async function checkLxc() { if (process.env.SCRYPTED_INSTALL_ENVIRONMENT !== SCRYPTED_INSTALL_ENVIRONMENT_LXC_DOCKER) return; + await checkLxcCompose(); + await checkLxcScript(); +} + +async function checkLxcCompose() { + // the lxc-docker used watchtower for automatic updates but watchtower started crashing in the lxc environment + // after a docker update. + // watchtower was removed from the lxc as a result. + // however existing installations may still have watchtower in their docker-compose.yml and need it removed. + const dockerCompose = yaml.parseDocument(readFileAsString('/root/.scrypted/docker-compose.yml')); + // @ts-ignore + const watchtower = dockerCompose.contents.get('services').get('watchtower'); + if (watchtower.get('profiles')) + return; + watchtower.set('profiles', ['disabled']); + writeFileSync('/root/.scrypted/docker-compose.yml', yaml.stringify(dockerCompose)); +} + +async function checkLxcScript() { const foundDockerComposeSh = await fs.promises.readFile(DOCKER_COMPOSE_SH_PATH, 'utf8'); const dockerComposeSh = await fs.promises.readFile(LXC_DOCKER_COMPOSE_SH_PATH, 'utf8'); @@ -34,4 +55,4 @@ export async function checkLxc() { // console.warn(foundDockerComposeSh); await fs.promises.copyFile(LXC_DOCKER_COMPOSE_SH_PATH, DOCKER_COMPOSE_SH_PATH); await fs.promises.chmod(DOCKER_COMPOSE_SH_PATH, 0o755); -} +} \ No newline at end of file