39 lines
1.2 KiB
TypeScript

// Minimal EasyPanel template generator that emits the canonical docker-compose
// and an .env file. This follows the standard LibreTime Docker deployment and
// does not add any extra services (e.g. composer).
import { Template } from '@easypanel/template-sdk';
const fs = require('fs');
const t: Template = {
meta: require('./meta.yaml'),
render: (values: any) => {
const composePath = './docker-compose.yml';
let composeContent = '';
try {
composeContent = fs.readFileSync(composePath, 'utf8');
} catch (e) {
composeContent = '# docker-compose source not found: ' + composePath + '\n';
}
const env = `POSTGRES_PASSWORD=${values.postgres_password || ''}\nRABBITMQ_DEFAULT_PASS=${values.rabbitmq_password || ''}\nLIBRETIME_GENERAL_PUBLIC_URL=${values.public_url || 'http://{{hostname}}:8080'}\n`;
let nginxConf = '';
try {
nginxConf = fs.readFileSync('./docker/nginx/default.conf', 'utf8');
} catch (e) {
nginxConf = '';
}
return {
files: [
{ path: 'docker-compose.yml', content: composeContent },
{ path: '.env', content: env },
{ path: 'docker/nginx/default.conf', content: nginxConf },
],
};
},
};
export default t;