Skip to content

Commit c9a2057

Browse files
committed
Add setup for DynamoDB.
1 parent 5fa52eb commit c9a2057

File tree

5 files changed

+60
-14
lines changed

5 files changed

+60
-14
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
docker-compose.override.yml
2+
.env

README.md

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,24 @@
11
# Local Docker DB
22

3-
## What?
3+
A collection of Docker Compose files I've used to quickly spin up local databases of various sorts.
44

5-
A collection of Docker Compose files I've used to quickly spin local databases of various sorts.
5+
# Included Databases
66

7-
## Why?
7+
Database | Docker Compose Configuration | Website
8+
---------- | ---------------------------- | ----------------------------------
9+
DynamoDB | [./dynamo](./dynamo/) | <https://aws.amazon.com/dynamodb/>
10+
Fauna | [./fauna](./fauna/) | <https://fauna.com/>
11+
MariaDB | [./maria](./maria/) | <https://mariadb.org/>
12+
MongoDB | [./mongo](./mongo/) | <https://www.mongodb.com/>
13+
MySQL | [./mysql](./mysql/) | <https://www.mysql.com/>
14+
PostgreSQL | [./postgres](./postgres/) | <https://www.postgresql.org/>
15+
Redis | [./redis](./redis/) | <https://redis.io/>
816

9-
Because I've oft needed them, particularly when I just don't wanna deal with the hassle of spinning up a DB on my own system.
17+
## Usage
1018

11-
## How?
19+
Clone the repo or copy a `docker-compose.yml` file to your system, `cd` into that directory, and turn it on with `docker-compose up` (unless otherwise noted by the directory's `README.md`). You may also use a `docker-compose.override.yml` file inside this repository to customize a container.
1220

13-
Clone the repo or copy a `docker-compose.yml` file to your system, `cd` into that directory, and turn it on with `docker-compose up`. You may also use a `docker-compose.override.yml` file inside this repository to customize a container. For a full reference on how to use Docker Compose, [go here](https://docs.docker.com/compose/reference/).
14-
15-
## Explore a Container w/ Bash
16-
17-
In any given container, run the following. Most of the time, the service name will just be `db`, but there may be an exception or two.
18-
19-
```
20-
docker-compose exec --user root SERVICE_NAME /bin/bash
21-
```
21+
For a full reference on how to use Docker Compose, [go here](https://docs.docker.com/compose/reference/).
2222

2323
## Local Persistence
2424

dynamo/.env-sample

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
AWS_ACCESS_KEY_ID=
2+
AWS_SECRET_ACCESS_KEY=
3+
AWS_DEFAULT_REGION=

dynamo/README.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# DyanmoDB w/ Docker Compose
2+
3+
## Starting the Container
4+
5+
Run `docker-compose up db` to turn on the DynamoDB container. After starting, the DB instance will be running at `http://localhost:8000`.
6+
7+
## Accessing the DB w/ the AWS CLI
8+
9+
Run `cp .env-sample .env` to create a new `.env` file, and fill the variables with your AWS credentials.
10+
11+
In order to run `aws` CLI commands against the locally-running DyanmoDB instance, use `docker-compose run aws SOME_AWS_COMMAND`. For example, referencing the DyanmoDB [developer guide](https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/getting-started-step-1.html), you could create a table by running the following:
12+
13+
```bash
14+
docker-compose run aws dynamodb create-table --table-name Music --attribute-definitions AttributeName=Artist,AttributeType=S AttributeName=SongTitle,AttributeType=S --key-schema AttributeName=Artist,KeyType=HASH AttributeName=SongTitle,KeyType=RANGE --provisioned-throughput ReadCapacityUnits=10,WriteCapacityUnits=5
15+
```
16+
17+
And then list all tables by running this:
18+
19+
```bash
20+
docker-compose run aws dynamodb list-tables
21+
```

dynamo/docker-compose.yml

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
version: '3'
2+
3+
services:
4+
db:
5+
command: -jar DynamoDBLocal.jar -sharedDb -dbPath ./data
6+
image: amazon/dynamodb-local:latest
7+
ports:
8+
- 8000:8000
9+
volumes:
10+
- dbdata:/home/dynamodblocal
11+
aws:
12+
depends_on:
13+
- db
14+
image: banst/awscli
15+
ports:
16+
- 8080:8080
17+
env_file:
18+
- .env
19+
20+
volumes:
21+
dbdata:

0 commit comments

Comments
 (0)