Skip to content

Instantly share code, notes, and snippets.

@giathinh910
Created November 21, 2024 02:55
Show Gist options
  • Save giathinh910/112e600403d774983779af650ab5b977 to your computer and use it in GitHub Desktop.
Save giathinh910/112e600403d774983779af650ab5b977 to your computer and use it in GitHub Desktop.
Create latest a Docker image with latest DynamoDB Local and DynamoDB Admin. To run `docker run --name <container-name> -itd -p 8000:8000 -p 8001:8001 <your-given-image-name>`.
# Use a base image with Node.js and Java (required for DynamoDB Local)
FROM openjdk:11-jdk-slim as dynamodb-admin
# Install Node.js and DynamoDB Admin
RUN apt-get update && apt-get install -y curl && \
curl -fsSL https://deb.nodesource.com/setup_16.x | bash - && \
apt-get install -y nodejs && \
npm install -g dynamodb-admin
# Download DynamoDB Local
WORKDIR /app
RUN curl -O https://s3.us-west-2.amazonaws.com/dynamodb-local/dynamodb_local_latest.tar.gz && \
tar -xvzf dynamodb_local_latest.tar.gz && \
rm dynamodb_local_latest.tar.gz
# Set environment variables for DynamoDB Admin
ENV DYNAMO_ENDPOINT=http://localhost:8000
# Expose both ports
EXPOSE 8000 8001
# Start both services
CMD sh -c "java -jar DynamoDBLocal.jar -sharedDb & sleep 2 && dynamodb-admin --port 8001"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment