scripts/nginx_config_maker/index.mjs

64 lines
1.5 KiB
JavaScript

/**
* setup domains
* @type {{framework: string, domain: string}[]}
*/
import fs from 'node-fs'
import { makeHostFileForWordpress } from './model.wordpress.mjs'
import { makeHostFileForSymfony } from './model.symfony.mjs'
const LXCcontainerLocalIP = '10.10.10.103'
const LXCcontainerProtocol = 'https'
const domainsConfig = [{
LXCcontainerLocalIP,
LXCcontainerProtocol,
name: 'Blog cipherbliss',
domain: 'www.cipherbliss.com',
framework: 'wordpress',
disableSSL: false,
}, {
LXCcontainerLocalIP,
LXCcontainerProtocol,
name: 'Funky Framadate Démo',
domain: 'framadate-api.cipherbliss.com',
framework: 'symfony',
disableSSL: false,
},
{
LXCcontainerLocalIP,
LXCcontainerProtocol,
name: 'Caisse Bliss',
domain: 'caisse.cipherbliss.com',
framework: 'symfony',
disableSSL: false,
},
]
for (let configDomain of domainsConfig) {
console.log('domaine :', configDomain.name)
let hostFile
if (configDomain.framework === 'wordpress') {
hostFile = makeHostFileForWordpress(configDomain)
}
if (configDomain.framework === 'symfony') {
hostFile = makeHostFileForSymfony(configDomain)
}
writeFile(configDomain.domain + '.host.conf', hostFile.homeNginxConf)
writeFile(configDomain.domain + '.container.conf', hostFile.containerNginxConf)
}
function writeFile (fileName, fileContent) {
console.log('write file', fileName)
return fs.writeFile(
`./output/${fileName}`,
fileContent,
'utf8',
(err) => {
if (err) {
console.log(`Error writing file: ${err}`)
}
}
)
}