我们有一个CircleCI脚本来管理我们的部署。我想允许DynamoDB Local运行,以便我们可以测试DynamoDB请求。我尝试按照答案here,here和here进行操作。我也尝试使用Docker Hub here中的DynamoDB本地映像。这是我最近得到的。
version: 2
jobs:
setup-dynamodb:
docker:
- image: openjdk:15-jdk
steps:
- setup_remote_docker:
version: 18.06.0-ce
- run:
name: run-dynamodb-local
background: true
shell: /bin/bash
command: |
curl -k -L -o dynamodb-local.tgz http://dynamodb-local.s3-website-us-west-2.amazonaws.com/dynamodb_local_latest.tar.gz
tar -xzf dynamodb-local.tgz
java -Djava.library.path=./DynamoDBLocal_lib -jar DynamoDBLocal.jar -port 8000 -sharedDb
check-failed:
docker:
- image: golang:1.14.3
steps:
- checkout
- setup_remote_docker:
version: 18.06.0-ce
- attach_workspace:
at: /tmp/app/workspace
- run:
name: Install dockerize
shell: /bin/bash
command: |
yum -y update && \
yum -y install wget && \
yum install -y tar.x86_64 && \
yum clean all
wget https://github.com/jwilder/dockerize/releases/download/$DOCKERIZE_VERSION/dockerize-linux-amd64-$DOCKERIZE_VERSION.tar.gz && \
tar -C /usr/local/bin -xzvf dockerize-linux-amd64-$DOCKERIZE_VERSION.tar.gz && \
rm dockerize-linux-amd64-$DOCKERIZE_VERSION.tar.gz
environment:
DOCKERIZE_VERSION: v0.3.0
- run:
name: Wait for Local DynamoDB
command: dockerize -wait tcp://localhost:8000 -timeout 1m
- run:
name: checkerr
shell: /bin/bash
command: |
ls -laF /tmp/app/workspace/
for i in $(seq 1 2); do
f=$(printf "failed%d.txt" $i)
value=$(</tmp/app/workspace/$f)
if [[ "$value" != "nil" ]]; then
echo "$f = $value"
exit 1
fi
done
我遇到的问题是我的所有测试均失败,并显示错误消息dial tcp 127.0.0.1:8000: connect: connection refused
。我不确定为什么会这样。我需要从容器中暴露端口吗?
原因是,第一份工作与第二份工作完全分开。
实际上,您不需要第一个,并如下调整第二个]
check-failed:
docker:
- image: golang:1.14.3
- image: amazon/dynamodb-local
steps:
- setup_remote_docker:
...
...
顺便说一下,您不需要每次都安装dynamodb,也可以作为容器运行