forked from UKGovLD/registry-deploy-env2016
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
5170944
commit 135a567
Showing
3 changed files
with
76 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
name: "Build & Publish Docker Image" | ||
on: | ||
workflow_dispatch: {} | ||
push: {} | ||
|
||
jobs: | ||
publish: | ||
uses: "epimorphics/github-workflows/.github/workflows/publish.yml@reusable" | ||
secrets: | ||
# Repostory specific | ||
aws_access_key_id: "${{ secrets.BUILD_LDS_AWS_ACCESS_KEY_ID }}" | ||
aws_secret_access_key: "${{ secrets.BUILD_LDS_AWS_SECRET_ACCESS_KEY }}" | ||
# Fixed | ||
epi_gpr_access_token: "${{ secrets.EPI_GPR_READ_ACCESS_TOKEN }}" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,55 @@ | ||
# build and push docker image to LDS ECR repository | ||
# Override verisons by setting variables (environment or make command line): | ||
# REGISTRY_VERSION (default 2.3.15) | ||
.PHONY: clean image publish tag test vars | ||
|
||
REGISTRY_VERSION?=2.3.15 | ||
IMAGE?=epimorphics/env-registry | ||
VERSION?=2.3.15 | ||
|
||
.PHONY: build | ||
build: | ||
docker build --build-arg REGISTRY_VERSION=$(REGISTRY_VERSION) -t "$(IMAGE):latest" . | ||
docker tag "$(IMAGE):latest" "$(IMAGE):$(REGISTRY_VERSION)" | ||
|
||
ACCOUNT?=$(shell aws sts get-caller-identity | jq -r .Account) | ||
AWS_REGION?=eu-west-1 | ||
ECR?=${ACCOUNT}.dkr.ecr.eu-west-1.amazonaws.com | ||
NAME?=$(shell awk -F: '$$1=="name" {print $$2}' deployment.yaml | sed -e 's/[[:blank:]]//g') | ||
SHORTNAME?=$(shell echo ${NAME} | cut -f2 -d/) | ||
STAGE?=dev | ||
|
||
COMMIT=$(shell git rev-parse --short HEAD) | ||
TAG?=$(shell printf '%s_%s_%08d' ${VERSION} ${COMMIT} ${GITHUB_RUN_NUMBER}) | ||
|
||
${TAG}: | ||
@echo ${TAG} | ||
|
||
IMAGE?=${NAME}/${STAGE} | ||
REPO?=${ECR}/${IMAGE} | ||
|
||
|
||
all: image | ||
|
||
clean: | ||
@echo | ||
|
||
image: | ||
@echo Building ${NAME}:${TAG} ... | ||
@docker build --build-arg REGISTRY_VERSION=$(VERSION) \ | ||
--tag ${NAME}:${TAG} \ | ||
. | ||
@echo Done. | ||
|
||
publish: image | ||
@echo Publishing image: ${REPO}:${TAG} ... | ||
@docker tag ${NAME}:${TAG} ${REPO}:${TAG} | ||
@docker push ${REPO}:${TAG} 2>&1 | ||
@echo Done. | ||
|
||
realclean: clean | ||
@rm -f ${GITHUB_TOKEN} ${BUNDLE_CFG} | ||
|
||
tag: | ||
@echo ${TAG} | ||
|
||
vars: | ||
@echo "Docker: ${REPO}:${TAG}" | ||
@echo "ACCOUNT = ${ACCOUNT}" | ||
@echo "ECR = ${ECR}" | ||
@echo "NAME = ${NAME}" | ||
@echo "STAGE = ${STAGE}" | ||
@echo "COMMIT = ${COMMIT}" | ||
@echo "TAG = ${TAG}" | ||
@echo "VERSION = ${VERSION}" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
version: 2 | ||
name: epimorphics/env-registry | ||
deployments: | ||
- branch: "production" | ||
publish: "production" | ||
- branch: "uat" | ||
publish: "uat" | ||
- branch: "master" | ||
publish: "dev" |