Skip to content

Commit

Permalink
Merge pull request #279 from henhal/docker-support
Browse files Browse the repository at this point in the history
Add support for running DynamoDB within docker
  • Loading branch information
AshanFernando authored Feb 7, 2022
2 parents 55ef657 + cc268b9 commit 0d44cc7
Showing 1 changed file with 29 additions and 3 deletions.
32 changes: 29 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,11 @@ serverless-dynamodb-local

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

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

Expand All @@ -24,7 +25,7 @@ plugins:
```
## Using the Plugin
1) Install DynamoDB Local
1) Install DynamoDB Local (unless using docker setup, see below)
`sls dynamodb install`

2) Add DynamoDB Resource definitions to your Serverless configuration, as defined here: https://serverless.com/framework/docs/providers/aws/guide/resources/#configuration
Expand All @@ -36,11 +37,16 @@ plugins:
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.

## Install: sls dynamodb install
This installs the Java program locally. If using docker, this step is not required.

To remove the installed dynamodb local, run:
`sls dynamodb remove`
Note: This is useful if the sls dynamodb install failed in between to completely remove and install a new copy of DynamoDB local.

## Start: sls dynamodb start
This starts the DynamoDB Local instance, either as a local Java program or, if the `--docker` flag is set,
by running it within a docker container. The default is to run it as a local Java program.

All CLI options are optional:

```
Expand All @@ -57,6 +63,8 @@ All CLI options are optional:
--migrate -m After starting DynamoDB local, create DynamoDB tables from the Serverless configuration.
--seed -s After starting and migrating dynamodb local, injects seed data into your tables. The --seed option determines which data categories to onload.
--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.
--docker Run DynamoDB inside docker container instead of as a local Java program
--dockerImage Specify custom docker image. Default: amazon/dynamodb-local
```

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

Docker setup:
```yml
custom:
dynamodb:
# If you only want to use DynamoDB Local in some stages, declare them here
stages:
- dev
start:
docker: true
port: 8000
inMemory: true
migrate: true
seed: true
convertEmptyValues: true
# Uncomment only if you already have a DynamoDB running locally
# noStart: true
```

## Migrations: sls dynamodb migrate
### Configuration
In `serverless.yml` add following to execute all the migration upon DynamoDB Local Start
Expand Down

0 comments on commit 0d44cc7

Please sign in to comment.