Skip to content

Commit

Permalink
templatize only Makefile include not makefile itself
Browse files Browse the repository at this point in the history
Signed-off-by: Gerd Oberlechner <[email protected]>
  • Loading branch information
geoberle committed Oct 25, 2024
1 parent 3830101 commit 0388bd1
Show file tree
Hide file tree
Showing 10 changed files with 36 additions and 59 deletions.
2 changes: 1 addition & 1 deletion backend/.gitignore
Original file line number Diff line number Diff line change
@@ -1 +1 @@
Makefile
config.mk
19 changes: 12 additions & 7 deletions backend/Makefile.tmpl.mk → backend/Makefile
Original file line number Diff line number Diff line change
@@ -1,14 +1,19 @@
SHELL = /bin/bash
DEPLOY_ENV ?= personal-dev

$(shell ../templatize.sh $(DEPLOY_ENV) config.tmpl.mk config.mk)

include config.mk

COMMIT = $(shell git rev-parse --short=7 HEAD)
ARO_HCP_BASE_IMAGE ?= {{ .acrName }}.azurecr.io
ARO_HCP_BASE_IMAGE ?= ${ARO_HCP_IMAGE_ACR}.azurecr.io
ARO_HCP_BACKEND_IMAGE ?= $(ARO_HCP_BASE_IMAGE)/arohcpbackend:$(COMMIT)

backend:
go build -o aro-hcp-backend .

run:
./aro-hcp-backend --location {{ .region }} \
./aro-hcp-backend --location ${LOCATION} \
--clusters-service-url http://localhost:8000

clean:
Expand All @@ -24,20 +29,20 @@ push: image

deploy:
BACKEND_MI_CLIENT_ID=$(shell az identity show \
-g {{ .serviceClusterRG }} \
-g ${RESOURCEGROUP} \
-n backend \
--query clientId);\
ISTO_VERSION=$(shell az aks show -n {{ .aksName }} -g {{ .serviceClusterRG }} --query serviceMeshProfile.istio.revisions[-1] -o tsv) && \
ISTO_VERSION=$(shell az aks show -n ${AKS_NAME} -g ${RESOURCEGROUP} --query serviceMeshProfile.istio.revisions[-1] -o tsv) && \
kubectl create namespace aro-hcp --dry-run=client -o json | kubectl apply -f - && \
kubectl label namespace aro-hcp "istio.io/rev=$${ISTO_VERSION}" --overwrite=true && \
helm upgrade --install aro-hcp-backend-dev \
deploy/helm/backend/ \
--set configMap.databaseName={{ .frontendCosmosDBName }} \
--set configMap.databaseUrl="https://{{ .frontendCosmosDBName }}.documents.azure.com:443/" \
--set configMap.databaseName=${DB_NAME} \
--set configMap.databaseUrl="https://${DB_NAME}.documents.azure.com:443/" \
--set configMap.backendMiClientId="$${BACKEND_MI_CLIENT_ID}" \
--set serviceAccount.workloadIdentityClientId="$${BACKEND_MI_CLIENT_ID}" \
--set configMap.currentVersion=${ARO_HCP_BACKEND_IMAGE} \
--set configMap.location={{ .region }} \
--set configMap.location=${LOCATION} \
--set deployment.imageName=${ARO_HCP_BACKEND_IMAGE} \
--namespace aro-hcp

Expand Down
11 changes: 0 additions & 11 deletions backend/README.md

This file was deleted.

5 changes: 5 additions & 0 deletions backend/config.tmpl.mk
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
ARO_HCP_IMAGE_ACR ?= {{ .acrName }}
LOCATION ?= {{ .region }}
RESOURCEGROUP ?= {{ .serviceClusterRG }}
AKS_NAME ?= {{ .aksName }}
DB_NAME ?= {{ .frontendCosmosDBName }}
12 changes: 0 additions & 12 deletions backend/generate-makefile.sh

This file was deleted.

2 changes: 1 addition & 1 deletion frontend/.gitignore
Original file line number Diff line number Diff line change
@@ -1 +1 @@
Makefile
config.mk
19 changes: 12 additions & 7 deletions frontend/Makefile.tmpl.mk → frontend/Makefile
Original file line number Diff line number Diff line change
@@ -1,14 +1,19 @@
SHELL = /bin/bash
DEPLOY_ENV ?= personal-dev

$(shell ../templatize.sh $(DEPLOY_ENV) config.tmpl.mk config.mk)

include config.mk

COMMIT = $(shell git rev-parse --short=7 HEAD)
ARO_HCP_BASE_IMAGE ?= {{ .acrName }}.azurecr.io
ARO_HCP_BASE_IMAGE ?=${ARO_HCP_IMAGE_ACR}.azurecr.io
ARO_HCP_FRONTEND_IMAGE ?= $(ARO_HCP_BASE_IMAGE)/arohcpfrontend:$(COMMIT)

frontend:
go build -o aro-hcp-frontend .

run:
./aro-hcp-frontend --use-cache --location {{ .region }} \
./aro-hcp-frontend --use-cache --location ${LOCATION} \
--clusters-service-url http://localhost:8000 \
--cluster-service-provision-shard 1 \
--cluster-service-noop-provision \
Expand All @@ -29,20 +34,20 @@ push: image

deploy:
FRONTEND_MI_CLIENT_ID=$(shell az identity show \
-g {{ .serviceClusterRG }} \
-g ${RESOURCEGROUP} \
-n frontend \
--query clientId);\
ISTO_VERSION=$(shell az aks show -n {{ .aksName }} -g {{ .serviceClusterRG }} --query serviceMeshProfile.istio.revisions[-1] -o tsv) && \
ISTO_VERSION=$(shell az aks show -n ${AKS_NAME} -g ${RESOURCEGROUP} --query serviceMeshProfile.istio.revisions[-1] -o tsv) && \
kubectl create namespace aro-hcp --dry-run=client -o json | kubectl apply -f - && \
kubectl label namespace aro-hcp "istio.io/rev=$${ISTO_VERSION}" --overwrite=true && \
helm upgrade --install aro-hcp-frontend-dev \
deploy/helm/frontend/ \
--set configMap.databaseName={{ .frontendCosmosDBName }} \
--set configMap.databaseUrl="https://{{ .frontendCosmosDBName }}.documents.azure.com:443/" \
--set configMap.databaseName=${DB_NAME} \
--set configMap.databaseUrl="https://${DB_NAME}.documents.azure.com:443/" \
--set configMap.frontendMiClientId="$${FRONTEND_MI_CLIENT_ID}" \
--set serviceAccount.workloadIdentityClientId="$${FRONTEND_MI_CLIENT_ID}" \
--set configMap.currentVersion=${ARO_HCP_FRONTEND_IMAGE} \
--set configMap.location={{ .region }} \
--set configMap.location=${LOCATION} \
--set deployment.imageName=${ARO_HCP_FRONTEND_IMAGE} \
--namespace aro-hcp

Expand Down
8 changes: 0 additions & 8 deletions frontend/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,6 @@

## Prerequisite

The `Makefile` is templated based on the ARO HCP environment to interact with.

Run the following command to generate a `Makefile` for personal development.

```bash
./generate-makefile.sh personal-dev
```

## Build frontend binary for local testing
```
make frontend
Expand Down
5 changes: 5 additions & 0 deletions frontend/config.tmpl.mk
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
ARO_HCP_IMAGE_ACR ?= {{ .acrName }}
LOCATION ?= {{ .region }}
RESOURCEGROUP ?= {{ .serviceClusterRG }}
AKS_NAME ?= {{ .aksName }}
DB_NAME ?= {{ .frontendCosmosDBName }}
12 changes: 0 additions & 12 deletions frontend/generate-makefile.sh

This file was deleted.

0 comments on commit 0388bd1

Please sign in to comment.