Skip to content

Commit 7e85211

Browse files
authored
Merge pull request #559 from bhtabor/persistent-docker-dynamodb
Serverless REST API with DynamoDB and offline support: optional persistent docker dynamodb setup
2 parents a0a94b4 + 2d6690e commit 7e85211

File tree

5 files changed

+28
-3
lines changed

5 files changed

+28
-3
lines changed

aws-node-rest-api-with-dynamodb-and-offline/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ Test your service locally, without having to deploy it first.
2727

2828
```bash
2929
npm install
30-
serverless dynamodb install
30+
serverless dynamodb install (or to use a persistent docker dynamodb instead, open a new terminal: cd ./dynamodb && docker-compose up -d)
3131
serverless offline start
3232
serverless dynamodb migrate (this imports schema)
3333
```
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
FROM amazon/dynamodb-local
2+
3+
WORKDIR /home/dynamodblocal
4+
5+
RUN mkdir ./db && chown -R 1000 ./db
6+
7+
CMD ["-jar", "DynamoDBLocal.jar", "-dbPath", "./db", "-sharedDb"]
8+
VOLUME ["./db"]
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
version: "3"
2+
3+
services:
4+
dynamodb:
5+
build:
6+
context: .
7+
dockerfile: Dockerfile
8+
ports:
9+
- 8000:8000
10+
volumes:
11+
- aws-rest-api-dynamodb:/home/dynamodblocal/db
12+
13+
volumes:
14+
aws-rest-api-dynamodb:
15+
driver: local

aws-node-rest-api-with-dynamodb-and-offline/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,6 @@
1111
"devDependencies": {
1212
"aws-sdk": "^2.12.0",
1313
"serverless-dynamodb-local": "^0.2.18",
14-
"serverless-offline": "^3.8.3"
14+
"serverless-offline": "^6.8.0"
1515
}
1616
}

aws-node-rest-api-with-dynamodb-and-offline/serverless.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
service: serverless-rest-api-with-dynamodb
22

3-
frameworkVersion: ">=1.1.0 <2.0.0"
3+
frameworkVersion: ">=1.1.0 <=2.4.0"
44

55
plugins:
66
- serverless-dynamodb-local
@@ -14,6 +14,8 @@ custom:
1414
port: 8000
1515
inMemory: true
1616
migrate: true
17+
# Comment if you don't have a DynamoDB running locally
18+
noStart: true
1719
migration:
1820
dir: offline/migrations
1921

0 commit comments

Comments
 (0)