Some checks are pending
Container / meta (analyzer) (push) Waiting to run
Container / meta (api) (push) Waiting to run
Container / meta (legacy) (push) Waiting to run
Container / meta (nginx) (push) Waiting to run
Container / meta (playout) (push) Waiting to run
Container / meta (worker) (push) Waiting to run
Container / build (push) Blocked by required conditions
Project / pre-commit (push) Waiting to run
Project / test-tools (push) Waiting to run
Release-Please / release-please (push) Waiting to run
43 lines
1.2 KiB
JavaScript
Executable File
43 lines
1.2 KiB
JavaScript
Executable File
#!/usr/bin/env node
|
|
"use strict";
|
|
|
|
// update.js - script de utilidad para EasyPanel
|
|
// Copia docker-compose.easypanel.yml a ./code/docker-compose.yml y elimina
|
|
// container_name y ports para que EasyPanel gestione nombres y puertos.
|
|
|
|
const fs = require('fs');
|
|
const path = require('path');
|
|
|
|
const SRC = path.resolve(__dirname, '../docker-compose.easypanel.yml');
|
|
const DEST_DIR = path.resolve(__dirname, './code');
|
|
const DEST = path.join(DEST_DIR, 'docker-compose.yml');
|
|
|
|
function removeContainerNamesAndPorts(content) {
|
|
// Eliminar container_name: <valor> líneas
|
|
content = content.replace(/^[ \t]*container_name:[^\n]*\n/gm, '');
|
|
// Eliminar bloques de ports:
|
|
// ports:\n - "..."\n - ...
|
|
content = content.replace(/^[ \t]*ports:[^\n]*\n(?:^[ \t]+-.*\n)*/gim, '');
|
|
return content;
|
|
}
|
|
|
|
async function main() {
|
|
if (!fs.existsSync(SRC)) {
|
|
console.error('ERROR: no se encuentra', SRC);
|
|
process.exit(2);
|
|
}
|
|
|
|
if (!fs.existsSync(DEST_DIR)) fs.mkdirSync(DEST_DIR, { recursive: true });
|
|
|
|
const raw = fs.readFileSync(SRC, 'utf8');
|
|
const sanitized = removeContainerNamesAndPorts(raw);
|
|
|
|
fs.writeFileSync(DEST, sanitized, 'utf8');
|
|
console.log('Preparado', DEST);
|
|
}
|
|
|
|
main().catch(err => {
|
|
console.error(err);
|
|
process.exit(1);
|
|
});
|