Skip to content

Commit 0d44cc7

Browse files
Merge pull request #279 from henhal/docker-support
Add support for running DynamoDB within docker
2 parents 55ef657 + cc268b9 commit 0d44cc7

File tree

1 file changed

+29
-3
lines changed

1 file changed

+29
-3
lines changed

README.md

Lines changed: 29 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,11 @@ serverless-dynamodb-local
77

88
## This Plugin Requires
99
* serverless@^1
10-
* Java Runtime Engine (JRE) version 6.x or newer
10+
* Java Runtime Engine (JRE) version 6.x or newer _OR_ docker CLI client
1111

1212
## Features
13-
* Install DynamoDB Local
13+
* Install DynamoDB Local Java program
14+
* Run DynamoDB Local as Java program on the local host or in docker container
1415
* Start DynamoDB Local with all the parameters supported (e.g port, inMemory, sharedDb)
1516
* Table Creation for DynamoDB Local
1617

@@ -24,7 +25,7 @@ plugins:
2425
```
2526
2627
## Using the Plugin
27-
1) Install DynamoDB Local
28+
1) Install DynamoDB Local (unless using docker setup, see below)
2829
`sls dynamodb install`
2930

3031
2) Add DynamoDB Resource definitions to your Serverless configuration, as defined here: https://serverless.com/framework/docs/providers/aws/guide/resources/#configuration
@@ -36,11 +37,16 @@ plugins:
3637
Note: Read the detailed section for more information on advanced options and configurations. Open a browser and go to the url http://localhost:8000/shell to access the web shell for dynamodb local.
3738

3839
## Install: sls dynamodb install
40+
This installs the Java program locally. If using docker, this step is not required.
41+
3942
To remove the installed dynamodb local, run:
4043
`sls dynamodb remove`
4144
Note: This is useful if the sls dynamodb install failed in between to completely remove and install a new copy of DynamoDB local.
4245

4346
## Start: sls dynamodb start
47+
This starts the DynamoDB Local instance, either as a local Java program or, if the `--docker` flag is set,
48+
by running it within a docker container. The default is to run it as a local Java program.
49+
4450
All CLI options are optional:
4551

4652
```
@@ -57,6 +63,8 @@ All CLI options are optional:
5763
--migrate -m After starting DynamoDB local, create DynamoDB tables from the Serverless configuration.
5864
--seed -s After starting and migrating dynamodb local, injects seed data into your tables. The --seed option determines which data categories to onload.
5965
--convertEmptyValues -e Set to true if you would like the document client to convert empty values (0-length strings, binary buffers, and sets) to be converted to NULL types when persisting to DynamoDB.
66+
--docker Run DynamoDB inside docker container instead of as a local Java program
67+
--dockerImage Specify custom docker image. Default: amazon/dynamodb-local
6068
```
6169

6270
All the above options can be added to serverless.yml to set default configuration: e.g.
@@ -79,6 +87,24 @@ custom:
7987
# noStart: true
8088
```
8189

90+
Docker setup:
91+
```yml
92+
custom:
93+
dynamodb:
94+
# If you only want to use DynamoDB Local in some stages, declare them here
95+
stages:
96+
- dev
97+
start:
98+
docker: true
99+
port: 8000
100+
inMemory: true
101+
migrate: true
102+
seed: true
103+
convertEmptyValues: true
104+
# Uncomment only if you already have a DynamoDB running locally
105+
# noStart: true
106+
```
107+
82108
## Migrations: sls dynamodb migrate
83109
### Configuration
84110
In `serverless.yml` add following to execute all the migration upon DynamoDB Local Start

0 commit comments

Comments
 (0)