-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathrunWithDocker.js
More file actions
29 lines (22 loc) · 972 Bytes
/
runWithDocker.js
File metadata and controls
29 lines (22 loc) · 972 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
const fs = require('node:fs');
const path = require('node:path');
const { execSync } = require('node:child_process');
require('dotenv').config();
const jarPath = process.env.POWPEG_NODE_JAR_PATH;
const removeContainerAfterExecution =
process.env.DOCKER_REMOVE_CONTAINER_AFTER_EXECUTION === 'true';
const removeContainerAfterExecutionFlag = removeContainerAfterExecution ? '--rm' : '';
if (jarPath) {
const destPath = path.join(__dirname, 'federate-node.jar');
console.log(`Copying JAR from ${jarPath} to ${destPath}`);
fs.copyFileSync(jarPath, destPath);
} else {
console.log('POWPEG_NODE_JAR_PATH is not set. Skipping file copy.');
}
console.log('Building Docker image...');
execSync('docker buildx build --platform linux/amd64 -t rits .', { stdio: 'inherit' });
console.log('Running Docker container...');
execSync(
`docker run --name rits --platform linux/amd64 -it ${removeContainerAfterExecutionFlag} rits`,
{ stdio: 'inherit' }
);