budibase/hosting/scripts/airgapped/airgappedDockerBuild.js

56 lines
1.1 KiB
JavaScript
Raw Normal View History

2021-10-28 13:29:00 +02:00
const fs = require("fs")
const { execSync } = require("child_process")
const path = require("path")
const IS_SINGLE_IMAGE = process.env.SINGLE_IMAGE
let IMAGES = {
2021-10-28 13:29:00 +02:00
worker: "budibase/worker",
apps: "budibase/apps",
2022-02-01 11:02:37 +01:00
proxy: "budibase/proxy",
2021-10-28 13:29:00 +02:00
minio: "minio/minio",
couch: "ibmcom/couchdb3",
curl: "curlimages/curl",
redis: "redis",
}
if (IS_SINGLE_IMAGE) {
IMAGES = {
budibase: "budibase/budibase"
}
2021-10-28 13:29:00 +02:00
}
const FILES = {
COMPOSE: "docker-compose.yaml",
2022-02-18 15:43:07 +01:00
ENV: ".env"
2021-10-28 13:29:00 +02:00
}
const OUTPUT_DIR = path.join(__dirname, "../", "bb-airgapped")
function copyFile(file) {
fs.copyFileSync(
path.join(__dirname, "../", "../", file),
path.join(OUTPUT_DIR, file)
)
}
// create output dir
console.log(`Creating ${OUTPUT_DIR} for build..`)
fs.rmdirSync(OUTPUT_DIR, { recursive: true })
fs.mkdirSync(OUTPUT_DIR)
// package images into tar files
for (let image in IMAGES) {
console.log(`Creating tar for ${image}..`)
execSync(`docker save ${IMAGES[image]} -o ${OUTPUT_DIR}/${image}.tar`)
}
// copy config files
if (!IS_SINGLE_IMAGE) {
copyFile(FILES.COMPOSE)
}
2022-02-18 15:43:07 +01:00
copyFile(FILES.ENV)
2021-10-28 13:29:00 +02:00
// compress
execSync(`tar -czf bb-airgapped.tar.gz hosting/scripts/bb-airgapped`)