Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for dockerized DynamoDBLocal #64

Merged
merged 1 commit into from
Jan 21, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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