Merge branch 'feature/t31-build-push-nodecast-and-laya-images' into develop (#31)

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
blomios
2026-10-06 21:18:40 +02:00
3 changed files with 70 additions and 2 deletions

View File

@ -117,7 +117,7 @@ LAYA_BASE_URL=http://localhost:8000 npm start
`http://laya:8000` is a Compose-internal hostname and does not resolve from a host process. `http://laya:8000` is a Compose-internal hostname and does not resolve from a host process.
Repository maintainers can still build and publish the nodecast-tv image with `./scripts/docker-build-push.sh`; this script is not needed by Compose users. Repository maintainers can build and publish both the nodecast-tv and Laya images with `./scripts/docker-build-push.sh`; this script is not needed by Compose users. `REGISTRY`, `OWNER`, `IMAGE_NAME`, `LAYA_IMAGE_NAME`, and `TAG` can override the publication targets. Use `--no-push` to build both images locally without publishing them.
### Hardware Acceleration Setup ### Hardware Acceleration Setup

View File

@ -5,8 +5,10 @@ set -euo pipefail
REGISTRY=${REGISTRY:-gitea.anthonybouteiller.ovh} REGISTRY=${REGISTRY:-gitea.anthonybouteiller.ovh}
OWNER=${OWNER:-blomios} OWNER=${OWNER:-blomios}
IMAGE_NAME=${IMAGE_NAME:-nodecast-tv} IMAGE_NAME=${IMAGE_NAME:-nodecast-tv}
LAYA_IMAGE_NAME=${LAYA_IMAGE_NAME:-nodecast-tv-laya}
TAG=${TAG:-latest} TAG=${TAG:-latest}
IMAGE="${REGISTRY}/${OWNER}/${IMAGE_NAME}:${TAG}" IMAGE="${REGISTRY}/${OWNER}/${IMAGE_NAME}:${TAG}"
LAYA_IMAGE="${REGISTRY}/${OWNER}/${LAYA_IMAGE_NAME}:${TAG}"
push_image=true push_image=true
if [[ "${1:-}" == "--no-push" ]]; then if [[ "${1:-}" == "--no-push" ]]; then
@ -23,8 +25,10 @@ fi
repo_dir=$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd) repo_dir=$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)
echo "Target image: ${IMAGE}" echo "Target Nodecast image: ${IMAGE}"
echo "Target Laya image: ${LAYA_IMAGE}"
docker build --file "${repo_dir}/Dockerfile" --tag "${IMAGE}" "${repo_dir}" docker build --file "${repo_dir}/Dockerfile" --tag "${IMAGE}" "${repo_dir}"
docker build --file "${repo_dir}/Dockerfile.laya" --tag "${LAYA_IMAGE}" "${repo_dir}"
if [[ "${DRY_RUN:-false}" == "true" || "${push_image}" == "false" ]]; then if [[ "${DRY_RUN:-false}" == "true" || "${push_image}" == "false" ]]; then
echo "Push skipped." echo "Push skipped."
@ -32,3 +36,4 @@ if [[ "${DRY_RUN:-false}" == "true" || "${push_image}" == "false" ]]; then
fi fi
docker push "${IMAGE}" docker push "${IMAGE}"
docker push "${LAYA_IMAGE}"

View File

@ -0,0 +1,63 @@
const test = require('node:test');
const assert = require('node:assert/strict');
const fs = require('node:fs');
const os = require('node:os');
const path = require('node:path');
const { spawnSync } = require('node:child_process');
const root = path.resolve(__dirname, '..');
const script = path.join(root, 'scripts', 'docker-build-push.sh');
function runWithMockDocker(args = [], env = {}) {
const dir = fs.mkdtempSync(path.join(os.tmpdir(), 'nodecast-docker-build-push-'));
const bin = path.join(dir, 'bin');
fs.mkdirSync(bin);
const log = path.join(dir, 'docker.log');
const docker = path.join(bin, 'docker');
fs.writeFileSync(docker, `#!/usr/bin/env bash\nprintf '%s\\n' "$*" >> "${log}"\n`);
fs.chmodSync(docker, 0o755);
const result = spawnSync('bash', [script, ...args], {
cwd: root,
env: {
...process.env,
PATH: `${bin}${path.delimiter}${process.env.PATH}`,
...env
},
encoding: 'utf8'
});
const commands = fs.existsSync(log) ? fs.readFileSync(log, 'utf8').trim().split('\n').filter(Boolean) : [];
fs.rmSync(dir, { recursive: true, force: true });
return {
result,
commands
};
}
test('docker build/push script builds and pushes Nodecast and Laya images by default', () => {
const { result, commands } = runWithMockDocker();
assert.equal(result.status, 0, result.stderr || result.stdout);
assert.deepEqual(commands, [
`build --file ${path.join(root, 'Dockerfile')} --tag gitea.anthonybouteiller.ovh/blomios/nodecast-tv:latest ${root}`,
`build --file ${path.join(root, 'Dockerfile.laya')} --tag gitea.anthonybouteiller.ovh/blomios/nodecast-tv-laya:latest ${root}`,
'push gitea.anthonybouteiller.ovh/blomios/nodecast-tv:latest',
'push gitea.anthonybouteiller.ovh/blomios/nodecast-tv-laya:latest'
]);
});
test('--no-push builds both images and skips both pushes', () => {
const { result, commands } = runWithMockDocker(['--no-push']);
assert.equal(result.status, 0, result.stderr || result.stdout);
assert.deepEqual(commands, [
`build --file ${path.join(root, 'Dockerfile')} --tag gitea.anthonybouteiller.ovh/blomios/nodecast-tv:latest ${root}`,
`build --file ${path.join(root, 'Dockerfile.laya')} --tag gitea.anthonybouteiller.ovh/blomios/nodecast-tv-laya:latest ${root}`
]);
});
test('DRY_RUN=true builds both images and skips both pushes', () => {
const { result, commands } = runWithMockDocker([], { DRY_RUN: 'true' });
assert.equal(result.status, 0, result.stderr || result.stdout);
assert.deepEqual(commands, [
`build --file ${path.join(root, 'Dockerfile')} --tag gitea.anthonybouteiller.ovh/blomios/nodecast-tv:latest ${root}`,
`build --file ${path.join(root, 'Dockerfile.laya')} --tag gitea.anthonybouteiller.ovh/blomios/nodecast-tv-laya:latest ${root}`
]);
});