Skip to content

Commit

Permalink
Merge pull request #64 from henhal/docker-support
Browse files Browse the repository at this point in the history
Add support for dockerized DynamoDBLocal
  • Loading branch information
AshanFernando authored Jan 21, 2022
2 parents 57457ba + 32439ea commit d88f777
Showing 1 changed file with 16 additions and 5 deletions.
21 changes: 16 additions & 5 deletions dynamodb/starter.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,17 +39,28 @@ var starter = {
additionalArgs.push('-help');
}

var args = ['-Djava.library.path=' + db_dir + '/DynamoDBLocal_lib', '-jar', jar, '-port', port];
args = preArgs.concat(args.concat(additionalArgs));
var args = ['-jar', jar, '-port', port];
var executable;
var cwd;

var child = spawn('java', args, {
cwd: db_dir,
if (options.docker) {
executable = process.env.DOCKER_PATH || 'docker';
preArgs = ['run', '-d', '-p', port + ':' + port, process.env.DOCKER_IMAGE || 'amazon/dynamodb-local'];
} else {
executable = 'java';
preArgs.push('-Djava.library.path=' + db_dir + '/DynamoDBLocal_lib');
cwd = db_dir;
}

args = preArgs.concat(args.concat(additionalArgs));
var child = spawn(executable, args, {
cwd: cwd,
env: process.env,
stdio: ['pipe', 'pipe', process.stderr]
});

if (!child.pid) {
throw new Error('Unable to start DynamoDB Local process! Make sure you have java executable in your path.');
throw new Error('Unable to start DynamoDB Local process! Make sure you have ' + executable + ' executable in your path.');
}

child.on('error', function (code) {
Expand Down

0 comments on commit d88f777

Please sign in to comment.