forked from tsai/budibase
committed by
GitHub
14 changed files with 138 additions and 914 deletions
@ -1,2 +0,0 @@ |
|||
FROM nginx:latest |
|||
COPY nginx.conf /etc/nginx/nginx.conf |
|||
@ -1,2 +1,2 @@ |
|||
FROM nginx:latest |
|||
COPY nginx.conf /etc/nginx/nginx.conf |
|||
COPY .generated-nginx.prod.conf /etc/nginx/nginx.conf |
|||
@ -0,0 +1,68 @@ |
|||
#!/usr/bin/env node
|
|||
const path = require("path") |
|||
const fs = require("fs") |
|||
const { processStringSync } = require("@budibase/string-templates") |
|||
|
|||
const Configs = { |
|||
prod: { |
|||
apps: "app-service.budibase.svc.cluster.local", |
|||
worker: "worker-service.budibase.svc.cluster.local", |
|||
minio: "minio-service.budibase.svc.cluster.local", |
|||
couchdb: "budibase-prod-svc-couchdb", |
|||
}, |
|||
preprod: { |
|||
apps: "app-service.budibase.svc.cluster.local", |
|||
worker: "worker-service.budibase.svc.cluster.local", |
|||
minio: "minio-service.budibase.svc.cluster.local", |
|||
couchdb: "budibase-preprod-svc-couchdb", |
|||
}, |
|||
compose: { |
|||
compose: true, |
|||
apps: "app-service", |
|||
worker: "worker-service", |
|||
minio: "minio-service", |
|||
couchdb: "couchdb-service", |
|||
watchtower: "watchtower-service", |
|||
}, |
|||
} |
|||
|
|||
const Commands = { |
|||
Prod: "prod", |
|||
Preprod: "preprod", |
|||
Compose: "compose", |
|||
} |
|||
|
|||
async function init(managementCommand) { |
|||
const config = Configs[managementCommand] |
|||
const hostingPath = path.join(process.cwd(), "..", "..", "hosting") |
|||
const nginxHbsPath = path.join(hostingPath, "nginx.prod.conf.hbs") |
|||
const nginxOutputPath = path.join( |
|||
hostingPath, |
|||
"proxy", |
|||
".generated-nginx.prod.conf" |
|||
) |
|||
const contents = fs.readFileSync(nginxHbsPath, "utf8") |
|||
fs.writeFileSync(nginxOutputPath, processStringSync(contents, config)) |
|||
} |
|||
|
|||
const managementCommand = process.argv.slice(2)[0] |
|||
|
|||
if ( |
|||
!managementCommand || |
|||
!Object.values(Commands).some(command => managementCommand === command) |
|||
) { |
|||
throw new Error( |
|||
"You must supply either a 'compose', 'preprod' or 'prod' commmand to generate an NGINX config." |
|||
) |
|||
} |
|||
|
|||
init(managementCommand) |
|||
.then(() => { |
|||
console.log("Done! 🎉") |
|||
}) |
|||
.catch(err => { |
|||
console.error( |
|||
"Something went wrong while creating the nginx configuration", |
|||
err.message |
|||
) |
|||
}) |
|||
File diff suppressed because it is too large
Loading…
Reference in new issue