Skip to content

Commit 4e8e270

Browse files
authored
Merge pull request #2 from metcalfc/ecs_make
Setting up to deploy to AWS ECS with Fargate
2 parents d43fe1f + 6042f5b commit 4e8e270

File tree

1 file changed

+15
-6
lines changed

1 file changed

+15
-6
lines changed

Makefile

+15-6
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@ endif
1010

1111
# Docker image tagging:
1212
HUB_USER?=${USER}
13+
14+
# When you create your secret use the DockerHub in the name and this will find it
15+
HUB_PULL_SECRET?=$(shell docker secret list | grep arn | grep DockerHub | cut -f1 -d' ')
1316
REPO?=$(shell basename ${PWD})
1417
TAG?=${GIT_TAG}
1518
DEV_IMAGE?=${REPO}:latest
@@ -28,31 +31,37 @@ dev:
2831
# Run the unit tests.
2932
.PHONY: build-test unit-test test
3033
unit-test:
31-
@docker build --progress plain --target test ./app
34+
@docker --context default build --progress plain --target test ./app
3235

3336
test: unit-test
3437

3538
# Build a production image for the application.
3639
.PHONY: build
3740
build:
38-
@docker build --target prod --tag ${PROD_IMAGE} ./app
41+
@docker --context default build --target prod --tag ${PROD_IMAGE} ./app
3942

4043
# Push the production image to a registry.
4144
.PHONY: push
4245
push: build
43-
@docker push ${PROD_IMAGE}
46+
@docker --context default push ${PROD_IMAGE}
4447

4548
# Run the production image either via compose or run
4649
.PHONY: deploy run
47-
deploy: build
48-
@PROD_IMAGE=${PROD_IMAGE} docker-compose up -d
50+
deploy: build push check-env
51+
HUB_PULL_SECRET=${HUB_PULL_SECRET} PROD_IMAGE=${PROD_IMAGE} docker compose up
4952

5053
run: build
51-
@docker run -d -p 5000:5000 ${PROD_IMAGE}
54+
@docker --context default run -d -p 5000:5000 ${PROD_IMAGE}
5255

5356
# Remove the dev container, dev image, test image, and clear the builder cache.
5457
.PHONY: clean
5558
clean:
5659
@docker-compose -f docker-compose.dev.yml down
5760
@docker rmi ${DEV_IMAGE} || true
5861
@docker builder prune --force --filter type=exec.cachemount --filter=unused-for=24h
62+
63+
.PHONY: check-env
64+
check-env:
65+
ifndef HUB_PULL_SECRET
66+
$(error HUB_PULL_SECRET is undefined. Use docker ecs secret ls to find the ARN)
67+
endif

0 commit comments

Comments
 (0)