diff --git a/.gitignore b/.gitignore index 7376571..215d7c8 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,2 @@ docker-compose.override.yml +.env diff --git a/README.md b/README.md index a8d0f61..a31e850 100644 --- a/README.md +++ b/README.md @@ -1,24 +1,24 @@ # Local Docker DB -## What? +A collection of Docker Compose files I've used to quickly spin up local databases of various sorts. -A collection of Docker Compose files I've used to quickly spin local databases of various sorts. +# Included Databases -## Why? +Database | Docker Compose Configuration | Website +---------- | ---------------------------- | ---------------------------------- +DynamoDB | [./dynamo](./dynamo/) | +Fauna | [./fauna](./fauna/) | +MariaDB | [./maria](./maria/) | +MongoDB | [./mongo](./mongo/) | +MySQL | [./mysql](./mysql/) | +PostgreSQL | [./postgres](./postgres/) | +Redis | [./redis](./redis/) | -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. +## Usage -## How? +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. -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/). - -## Explore a Container w/ Bash - -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. - -``` -docker-compose exec --user root SERVICE_NAME /bin/bash -``` +For a full reference on how to use Docker Compose, [go here](https://docs.docker.com/compose/reference/). ## Local Persistence diff --git a/dynamo/.env-sample b/dynamo/.env-sample new file mode 100644 index 0000000..f99d65c --- /dev/null +++ b/dynamo/.env-sample @@ -0,0 +1,3 @@ +AWS_ACCESS_KEY_ID= +AWS_SECRET_ACCESS_KEY= +AWS_DEFAULT_REGION= diff --git a/dynamo/README.md b/dynamo/README.md new file mode 100644 index 0000000..09f07c5 --- /dev/null +++ b/dynamo/README.md @@ -0,0 +1,21 @@ +# DyanmoDB w/ Docker Compose + +## Starting the Container + +Run `docker-compose up db` to turn on the DynamoDB container. After starting, the DB instance will be running at `http://localhost:8000`. + +## Accessing the DB w/ the AWS CLI + +Run `cp .env-sample .env` to create a new `.env` file, and fill the variables with your AWS credentials. + +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: + +```bash +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 +``` + +And then list all tables by running this: + +```bash +docker-compose run aws dynamodb list-tables +``` diff --git a/dynamo/docker-compose.yml b/dynamo/docker-compose.yml new file mode 100644 index 0000000..179cf38 --- /dev/null +++ b/dynamo/docker-compose.yml @@ -0,0 +1,21 @@ +version: '3' + +services: + db: + command: -jar DynamoDBLocal.jar -sharedDb -dbPath ./data + image: amazon/dynamodb-local:latest + ports: + - 8000:8000 + volumes: + - dbdata:/home/dynamodblocal + aws: + depends_on: + - db + image: banst/awscli + ports: + - 8080:8080 + env_file: + - .env + +volumes: + dbdata: