|
| 1 | +export DOCKER_ORG ?= acme |
| 2 | +export DOCKER_TAG ?= latest |
| 3 | +export ECR_IMAGE ?= infra-acme |
| 4 | +export DOCKER_IMAGE ?= $(DOCKER_ORG)/$(ECR_IMAGE) |
| 5 | +export DOCKER_IMAGE_NAME ?= $(DOCKER_IMAGE):$(DOCKER_TAG) |
| 6 | + |
| 7 | +# Name for app (used in banner and name of wrapper script) |
| 8 | +export APP_NAME ?= acme |
| 9 | + |
| 10 | +# Default install path, if lacking permissions, ~/.local/bin will be used instead |
| 11 | +export INSTALL_PATH ?= /usr/local/bin |
| 12 | + |
| 13 | +export TARGET_DOCKER_AWS_ACCOUNT_ID ?= 111111111111 |
| 14 | + |
| 15 | +export TARGET_DOCKER_AWS_REGION ?= us-east-1 |
| 16 | +export TARGET_DOCKER_REGISTRY := $(TARGET_DOCKER_AWS_ACCOUNT_ID).dkr.ecr.$(TARGET_DOCKER_AWS_REGION).amazonaws.com |
| 17 | +export TARGET_DOCKER_REPO := $(TARGET_DOCKER_REGISTRY)/$(DOCKER_IMAGE) |
| 18 | +export TARGET_VERSION ?= $(DOCKER_TAG) |
| 19 | +export TARGET_IMAGE_NAME := $(TARGET_DOCKER_REPO):$(TARGET_VERSION) |
| 20 | +export TARGET_DOCKER_PUSH_PROFILE ?= acme-core-gbl-artifacts-admin |
| 21 | + |
| 22 | +export ADR_DOCS_DIR = docs/adr |
| 23 | +export ADR_DOCS_README = $(ADR_DOCS_DIR)/README.md |
| 24 | + |
| 25 | +-include $(shell curl -sSL -o .build-harness "https://cloudposse.tools/build-harness"; echo .build-harness) |
| 26 | + |
| 27 | +.DEFAULT_GOAL := all |
| 28 | + |
| 29 | +.PHONY: all build build-clean install run run/new run/check push |
| 30 | + |
| 31 | + |
| 32 | +all: init deps build install run/new |
| 33 | + @exit 0 |
| 34 | + |
| 35 | +## Install dependencies (if any) |
| 36 | +deps: init |
| 37 | + @exit 0 |
| 38 | + |
| 39 | +## Build docker image |
| 40 | +build: export DOCKER_FILE=components/docker/infra-acme/Dockerfile |
| 41 | +build: |
| 42 | + @$(MAKE) --no-print-directory docker/build |
| 43 | + |
| 44 | +## Build docker image with no cache |
| 45 | +build-clean: export DOCKER_BUILD_FLAGS=--no-cache |
| 46 | +build-clean: build |
| 47 | + @exit 0 |
| 48 | + |
| 49 | +## Push docker image to registry |
| 50 | +push: |
| 51 | + @docker tag $(DOCKER_IMAGE_NAME) $(TARGET_IMAGE_NAME) |
| 52 | + @docker push $(TARGET_IMAGE_NAME) |
| 53 | + |
| 54 | +## Install wrapper script from geodesic container |
| 55 | +install: |
| 56 | + @docker run --rm \ |
| 57 | + --env APP_NAME=$(APP_NAME) \ |
| 58 | + --env DOCKER_IMAGE=$(DOCKER_IMAGE) \ |
| 59 | + --env DOCKER_TAG=$(DOCKER_TAG) \ |
| 60 | + --env INSTALL_PATH=$(INSTALL_PATH) \ |
| 61 | + $(DOCKER_IMAGE_NAME) | bash -s $(DOCKER_TAG) |
| 62 | + |
| 63 | +## Start the geodesic shell by calling wrapper script |
| 64 | +run: |
| 65 | + @$(APP_NAME) |
| 66 | + |
| 67 | +run/check: |
| 68 | + @if [[ -n "$$(docker ps --format {{ '{{ .Names }}' }} --filter name="^/$(APP_NAME)\$$")" ]]; then \ |
| 69 | + printf "**************************************************************************\n" ; \ |
| 70 | + printf "Not launching new container because old container is still running.\n"; \ |
| 71 | + printf "Exit all running container shells gracefully or kill the container with\n\n"; \ |
| 72 | + printf " docker kill %s\n\n" "$(APP_NAME)" ; \ |
| 73 | + printf "**************************************************************************\n" ; \ |
| 74 | + exit 9 ; \ |
| 75 | + fi |
| 76 | + |
| 77 | +run/new: run/check run |
| 78 | + @exit 0 |
| 79 | + |
| 80 | +.PHONY: terraform-rm-lockfiles rebuild-adr-docs rebuild-aws-config rebuild-docs ecr-auth |
| 81 | + |
| 82 | +## Remove all lock files |
| 83 | +terraform-rm-lockfiles: |
| 84 | + $(shell find . -name ".terraform.lock.hcl" -exec rm -v {} \;) |
| 85 | + |
| 86 | +## Rebuild README for all Terraform components |
| 87 | +rebuild-docs: packages/install/terraform-docs |
| 88 | + @pre-commit run --all-files terraform_docs |
| 89 | + |
| 90 | +## Rebuild README TOC for all ADRs |
| 91 | +rebuild-adr-docs: |
| 92 | + adr generate toc > $(ADR_DOCS_README); |
| 93 | + |
| 94 | +rebuild-aws-config: |
| 95 | + @printf "\nTo rebuild the AWS configuration files, from within the Geodesic shell ($(APP_NAME)), run:\n\n" >&2 |
| 96 | + @printf " atmos workflow update-aws-config -f identity\n\n" >&2 |
| 97 | + exit 1 |
| 98 | + |
| 99 | +## Authenticate with ECR repository |
| 100 | +ecr-auth: |
| 101 | + @AWS_PROFILE=$(TARGET_DOCKER_PUSH_PROFILE) aws ecr get-login-password --region us-east-1 | docker login --username AWS --password-stdin $(TARGET_DOCKER_REPO) |
0 commit comments