From 7ea05c571b645c7f9b68368dcc3b5392a00f0b0a Mon Sep 17 00:00:00 2001 From: Martin McKeaveney Date: Thu, 28 Oct 2021 13:29:00 +0200 Subject: [PATCH] airgapped docker build --- .gitignore | 1 + .../scripts/airgapped/airgappedDockerBuild.js | 49 +++++++++++++++++++ package.json | 1 + 3 files changed, 51 insertions(+) create mode 100755 hosting/scripts/airgapped/airgappedDockerBuild.js diff --git a/.gitignore b/.gitignore index 3a5fc5dc7b..086813c97e 100644 --- a/.gitignore +++ b/.gitignore @@ -3,6 +3,7 @@ builder/* .temp/ packages/server/runtime_apps/ .idea/ +bb-airgapped.tar.gz # Logs logs diff --git a/hosting/scripts/airgapped/airgappedDockerBuild.js b/hosting/scripts/airgapped/airgappedDockerBuild.js new file mode 100755 index 0000000000..7ca195ec6c --- /dev/null +++ b/hosting/scripts/airgapped/airgappedDockerBuild.js @@ -0,0 +1,49 @@ +const fs = require("fs") +const { execSync } = require("child_process") +const path = require("path") + +const IMAGES = { + worker: "budibase/worker", + apps: "budibase/apps", + proxy: "envoyproxy/envoy:v1.16-latest", + minio: "minio/minio", + couch: "ibmcom/couchdb3", + curl: "curlimages/curl", + redis: "redis", + watchtower: "containrrr/watchtower" +} + +const FILES = { + COMPOSE: "docker-compose.yaml", + ENVOY: "envoy.yaml" +} + +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 +copyFile(FILES.COMPOSE) +copyFile(FILES.ENVOY) + +// compress +execSync(`tar -czf bb-airgapped.tar.gz hosting/scripts/bb-airgapped`) + +// clean up +fs.rmdirSync(OUTPUT_DIR, { recursive: true }) \ No newline at end of file diff --git a/package.json b/package.json index eb7b7167f1..f0326782d1 100644 --- a/package.json +++ b/package.json @@ -46,6 +46,7 @@ "build:docker": "lerna run build:docker && cd hosting/scripts/linux/ && ./release-to-docker-hub.sh $BUDIBASE_RELEASE_VERSION && cd -", "build:docker:production": "lerna run build:docker && cd hosting/scripts/linux/ && ./release-to-docker-hub.sh $BUDIBASE_RELEASE_VERSION release && cd -", "build:docker:develop": "node scripts/pinVersions && lerna run build:docker && cd hosting/scripts/linux/ && ./release-to-docker-hub.sh develop && cd -", + "build:docker:airgap": "node hosting/scripts/airgapped/airgappedDockerBuild", "release:helm": "./scripts/release_helm_chart.sh", "env:multi:enable": "lerna run env:multi:enable", "env:multi:disable": "lerna run env:multi:disable",