Skip to content

Instantly share code, notes, and snippets.

@neilkidd
Last active October 7, 2021 18:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save neilkidd/fba9bc6af19f6bf8e930c004d022cd15 to your computer and use it in GitHub Desktop.
Save neilkidd/fba9bc6af19f6bf8e930c004d022cd15 to your computer and use it in GitHub Desktop.
version: "3.8"
services:
dynamodb-local:
container_name: app-dynamodb-local
command: "-jar DynamoDBLocal.jar -sharedDb -inMemory"
image: amazon/dynamodb-local
ports:
- "8000:8000"
# restart: unless-stopped
dynamodb-admin:
image: aaronshaf/dynamodb-admin
ports:
- "8001:8001"
environment:
- DYNAMO_ENDPOINT=http://host.docker.internal:8000
depends_on:
- dynamodb-local
awscli-dynamodb-migrator:
image: amazon/aws-cli
command: |
dynamodb create-table
--table-name casbin-table-dev
--attribute-definitions AttributeName=id,AttributeType=S
--key-schema AttributeName=id,KeyType=HASH
--provisioned-throughput ReadCapacityUnits=5,WriteCapacityUnits=5
--endpoint-url http://host.docker.internal:8000
environment:
- AWS_ACCESS_KEY_ID=unused
- AWS_SECRET_ACCESS_KEY=unused
- AWS_DEFAULT_REGION=us-east-1
depends_on:
- dynamodb-local
# restart: unless-stopped
@neilkidd
Copy link
Author

neilkidd commented Oct 7, 2021

Changed the dynamodb instance to have a command that loses the data each run and shares all tables.
command: "-jar DynamoDBLocal.jar -sharedDb -inMemory"
In practice the -inMemory option can be removed to persist the data and the migrator fails safely.

Switched to using http://host.docker.internal:8000 to work around oddities of running docker inside wsl2.
Need to comfirm this works on a mac please 🙇

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment