Skip to content

Commit da7ebb7

Browse files
authored
Improve the makefile setup (#1597)
* Remove containers when stopping them This ensures that starting the setup again picks up the new version of the image during the next run. * Clean docker setups in components The components should be pulling the images they launch and not a different tag. And they should not try to start the shared localstack container when the image they use is not localstack. Instead, the should check for the shared container created by the root Makefile * Clean all docker images of the root Makefile * Change the root Makefile to be consistent with services Instead of having `make stop-docker` triggering the `clean` command (which also triggers the cleaning of sub-services), it is now `clean` which depends on `stop-docker` of the root repo. This brings consistency with initialization commands. We now have a symmetry between `initialize`/`clean` and `start-docker`/`stop-docker`.
1 parent 556ebdc commit da7ebb7

File tree

16 files changed

+25
-6
lines changed

16 files changed

+25
-6
lines changed

Makefile

+7-2
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ SUBCLEAN = $(addsuffix .clean,$(COMPONENTS))
44
SUBINITIALIZE = $(addsuffix .initialize,$(COMPONENTS))
55

66
.PHONY: clean $(SUBCLEAN)
7-
clean: $(SUBCLEAN)
7+
clean: stop-docker $(SUBCLEAN)
88
$(SUBCLEAN): %.clean:
99
$(MAKE) -C $* clean
1010

@@ -30,8 +30,13 @@ start-docker-kms:
3030
docker start async_aws_kms && exit 0 || \
3131
docker run -d -p 4579:8080 --name async_aws_kms nsmithuk/local-kms
3232

33-
stop-docker: clean
33+
stop-docker:
3434
docker stop async_aws_localstack || true
35+
docker rm async_aws_localstack || true
36+
docker stop async_aws_s3 || true
37+
docker rm async_aws_s3 || true
38+
docker stop async_aws_kms || true
39+
docker rm async_aws_kms || true
3540

3641
test: initialize
3742
./vendor/bin/simple-phpunit

src/Core/Makefile

+1
Original file line numberDiff line numberDiff line change
@@ -14,3 +14,4 @@ test: initialize
1414
clean: stop-docker
1515
stop-docker:
1616
docker stop async_aws_localstack-sts || true
17+
docker rm async_aws_localstack-sts || true

src/Service/CloudFormation/Makefile

+1
Original file line numberDiff line numberDiff line change
@@ -14,3 +14,4 @@ test: initialize
1414
clean: stop-docker
1515
stop-docker:
1616
docker stop async_aws_localstack-cloudformation || true
17+
docker rm async_aws_localstack-cloudformation || true

src/Service/CloudWatchLogs/Makefile

+1
Original file line numberDiff line numberDiff line change
@@ -14,3 +14,4 @@ test: initialize
1414
clean: stop-docker
1515
stop-docker:
1616
docker stop async_aws_localstack-logs || true
17+
docker rm async_aws_localstack-logs || true

src/Service/DynamoDb/Makefile

+1
Original file line numberDiff line numberDiff line change
@@ -14,3 +14,4 @@ test: initialize
1414
clean: stop-docker
1515
stop-docker:
1616
docker stop async_aws_localstack-dynamodb || true
17+
docker rm async_aws_localstack-dynamodb || true

src/Service/EventBridge/Makefile

+1
Original file line numberDiff line numberDiff line change
@@ -14,3 +14,4 @@ test: initialize
1414
clean: stop-docker
1515
stop-docker:
1616
docker stop async_aws_localstack-events || true
17+
docker rm async_aws_localstack-events || true

src/Service/Iam/Makefile

+1
Original file line numberDiff line numberDiff line change
@@ -14,3 +14,4 @@ test: initialize
1414
clean: stop-docker
1515
stop-docker:
1616
docker stop async_aws_localstack-iam || true
17+
docker rm async_aws_localstack-iam || true

src/Service/Kinesis/Makefile

+1
Original file line numberDiff line numberDiff line change
@@ -14,3 +14,4 @@ test: initialize
1414
clean: stop-docker
1515
stop-docker:
1616
docker stop async_aws_localstack-kinesis || true
17+
docker rm async_aws_localstack-kinesis || true

src/Service/Kms/Makefile

+3-2
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22

33
initialize: start-docker
44
start-docker:
5-
docker start async_aws_localstack && exit 0 || \
5+
docker start async_aws_kms && exit 0 || \
66
docker start async_aws_localstack-kms && exit 0 || \
7-
docker pull localstack/localstack:0.14.2 && \
7+
docker pull nsmithuk/local-kms && \
88
docker run -d -p 4579:8080 --name async_aws_localstack-kms nsmithuk/local-kms && \
99
docker run --rm --link async_aws_localstack-kms:localstack martin/wait -c localstack:8080
1010

@@ -14,3 +14,4 @@ test: initialize
1414
clean: stop-docker
1515
stop-docker:
1616
docker stop async_aws_localstack-kms || true
17+
docker rm async_aws_localstack-kms || true

src/Service/Lambda/Makefile

+2-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ ROOT_DIR:=$(shell dirname $(realpath $(firstword $(MAKEFILE_LIST))))
55
initialize: start-docker
66
start-docker:
77
docker start async_aws_lambda && exit 0 || \
8-
docker pull lambci/lambda && \
8+
docker pull lambci/lambda:nodejs12.x && \
99
docker run -d -p 9001:9001 -e DOCKER_LAMBDA_STAY_OPEN=1 -v "$(ROOT_DIR)/tests/fixtures/lambda":/var/task:ro,delegated --name async_aws_lambda lambci/lambda:nodejs12.x index.handler
1010

1111
test: initialize
@@ -14,3 +14,4 @@ test: initialize
1414
clean: stop-docker
1515
stop-docker:
1616
docker stop async_aws_lambda || true
17+
docker rm async_aws_lambda || true

src/Service/Route53/Makefile

+1
Original file line numberDiff line numberDiff line change
@@ -14,3 +14,4 @@ test: initialize
1414
clean: stop-docker
1515
stop-docker:
1616
docker stop async_aws_localstack-route53 || true
17+
docker rm async_aws_localstack-route53 || true

src/Service/S3/Makefile

+1
Original file line numberDiff line numberDiff line change
@@ -13,3 +13,4 @@ test: initialize
1313
clean: stop-docker
1414
stop-docker:
1515
docker stop async_aws_s3-client || true
16+
docker rm async_aws_s3-client || true

src/Service/SecretsManager/Makefile

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,4 @@ test: initialize
1414
clean: stop-docker
1515
stop-docker:
1616
docker stop async_aws_localstack-secretsmanager || true
17-
17+
docker rm async_aws_localstack-secretsmanager || true

src/Service/Sns/Makefile

+1
Original file line numberDiff line numberDiff line change
@@ -14,3 +14,4 @@ test: initialize
1414
clean: stop-docker
1515
stop-docker:
1616
docker stop async_aws_localstack-sns || true
17+
docker rm async_aws_localstack-sns || true

src/Service/Sqs/Makefile

+1
Original file line numberDiff line numberDiff line change
@@ -12,3 +12,4 @@ test: initialize
1212
clean: stop-docker
1313
stop-docker:
1414
docker stop async_aws_sqs || true
15+
docker rm async_aws_sqs || true

src/Service/Ssm/Makefile

+1
Original file line numberDiff line numberDiff line change
@@ -14,3 +14,4 @@ test: initialize
1414
clean: stop-docker
1515
stop-docker:
1616
docker stop async_aws_localstack-ssm || true
17+
docker rm async_aws_localstack-ssm || true

0 commit comments

Comments
 (0)