-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore(NODE-6176): add prebuilds in CI
- Loading branch information
Showing
3 changed files
with
99 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
ARG NODE_BUILD_IMAGE=node:16.20.1-bullseye | ||
FROM $NODE_BUILD_IMAGE AS build | ||
|
||
WORKDIR /mongodb-client-encryption | ||
COPY . . | ||
|
||
RUN node ./.github/scripts/libmongocrypt.mjs | ||
RUN mkdir -p /out && cp -R /mongodb-client-encryption/prebuilds/ /out | ||
|
||
FROM scratch | ||
|
||
COPY --from=build /out / |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
import child_process from 'node:child_process'; | ||
import events from 'node:events'; | ||
import fs from 'node:fs/promises'; | ||
import path from 'node:path'; | ||
import url from 'node:url'; | ||
|
||
const __dirname = path.dirname(url.fileURLToPath(import.meta.url)); | ||
|
||
/** Resolves to the root of this repository */ | ||
function resolveRoot(...paths) { | ||
return path.resolve(__dirname, '..', '..', ...paths); | ||
} | ||
|
||
/** `xtrace` style command runner, uses spawn so that stdio is inherited */ | ||
async function run(command, args = [], options = {}) { | ||
const commandDetails = `+ ${command} ${args.join(' ')}${options.cwd ? ` (in: ${options.cwd})` : ''}` | ||
console.error(commandDetails); | ||
const proc = child_process.spawn(command, args, { | ||
stdio: 'inherit', | ||
cwd: resolveRoot('.'), | ||
...options | ||
}); | ||
await events.once(proc, 'exit'); | ||
|
||
if (proc.exitCode != 0) throw new Error(`CRASH(${proc.exitCode}): ${commandDetails}`); | ||
} | ||
|
||
async function main() { | ||
await fs.rm(resolveRoot('build'), { recursive: true, force: true }); | ||
await fs.rm(resolveRoot('prebuilds'), { recursive: true, force: true }); | ||
|
||
try { | ||
// Locally you probably already have this | ||
await run('docker', ['buildx', 'use', 'builder']); | ||
} catch { | ||
// But if not, create one | ||
await run('docker', ['buildx', 'create', '--name', 'builder', '--bootstrap', '--use']); | ||
} | ||
|
||
await run('docker', [ | ||
'buildx', | ||
'build', | ||
// '--progress=plain', // By default buildx detects tty and does some fancy collapsing, set progress=plain for debugging | ||
'--platform', | ||
'linux/s390x,linux/arm64,linux/amd64', | ||
'--output', | ||
'type=local,dest=.,platform-split=false', | ||
'-f', | ||
resolveRoot('./.github/docker/Dockerfile.glibc'), | ||
resolveRoot('.') | ||
]); | ||
} | ||
|
||
await main(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters