Skip to content

Commit

Permalink
Merge pull request #109 from mbarnes/frontend-make-targets
Browse files Browse the repository at this point in the history
Move frontend-specific make targets to frontend/Makefile
  • Loading branch information
s-amann authored May 8, 2024
2 parents 9e9068d + b91e92c commit 270da4a
Show file tree
Hide file tree
Showing 4 changed files with 61 additions and 58 deletions.
57 changes: 1 addition & 56 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,12 +1,4 @@
SHELL = /bin/bash
COMMIT = $(shell git rev-parse --short=7 HEAD)$(shell [[ $$(git status --porcelain) = "" ]] || echo -dirty)
ARO_HCP_BASE_IMAGE ?= ${ARO_HCP_IMAGE_ACR}.azurecr.io
ARO_HCP_FRONTEND_IMAGE ?= $(ARO_HCP_BASE_IMAGE)/arohcpfrontend:$(COMMIT)

# for deploying frontend into private aks cluster via invoke command
# these values must be set
RESOURCE_GROUP ?=
CLUSTER_NAME ?=

all: test lint

Expand All @@ -21,51 +13,4 @@ MODULES := $(shell go list -f '{{.Dir}}/...' -m | xargs)
lint:
golangci-lint run -v $(MODULES)

frontend-build-container:
docker build --platform="linux/amd64" -f "frontend/Dockerfile" -t ${ARO_HCP_FRONTEND_IMAGE} .

frontend-deploy:
@test "${RESOURCE_GROUP}" != "" || (echo "RESOURCE_GROUP must be defined" && exit 1)
FRONTEND_MI_CLIENT_ID=$(shell az deployment group show \
-g ${RESOURCE_GROUP} \
-n "hcp-${USER}-dev-infra" \
--query properties.outputs.frontend_mi_client_id.value);\
oc process -f ./deploy/aro-hcp-frontend.yml --local \
-p ARO_HCP_FRONTEND_IMAGE=${ARO_HCP_FRONTEND_IMAGE} \
-p FRONTEND_MI_CLIENT_ID="$${FRONTEND_MI_CLIENT_ID}" | oc apply -f -

frontend-undeploy:
@test "${RESOURCE_GROUP}" != "" || (echo "RESOURCE_GROUP must be defined" && exit 1)
FRONTEND_MI_CLIENT_ID=$(shell az deployment group show \
-g ${RESOURCE_GROUP} \
-n "hcp-${USER}-dev-infra" \
--query properties.outputs.frontend_mi_client_id.value);\
oc process -f ./deploy/aro-hcp-frontend.yml --local \
-p ARO_HCP_FRONTEND_IMAGE=${ARO_HCP_FRONTEND_IMAGE} \
-p FRONTEND_MI_CLIENT_ID="$${FRONTEND_MI_CLIENT_ID}" | oc delete -f -

frontend-deploy-private:
@test "${RESOURCE_GROUP}" != "" && test "${CLUSTER_NAME}" != "" || (echo "RESOURCE_GROUP and CLUSTER_NAME must be defined" && exit 1)
TMP_DEPLOY=$(shell mktemp);\
FRONTEND_MI_CLIENT_ID=$(shell az deployment group show \
-g ${RESOURCE_GROUP} \
-n "hcp-${USER}-dev-infra" \
--query properties.outputs.frontend_mi_client_id.value);\
oc process -f ./deploy/aro-hcp-frontend.yml --local \
-p ARO_HCP_FRONTEND_IMAGE=${ARO_HCP_FRONTEND_IMAGE} \
-p FRONTEND_MI_CLIENT_ID="$${FRONTEND_MI_CLIENT_ID}" > "$${TMP_DEPLOY}";\
az aks command invoke --resource-group ${RESOURCE_GROUP} --name ${CLUSTER_NAME} --command "kubectl create -f $$(basename $${TMP_DEPLOY})" --file "$${TMP_DEPLOY}"

frontend-undeploy-private:
@test "${RESOURCE_GROUP}" != "" && test "${CLUSTER_NAME}" != "" || (echo "RESOURCE_GROUP and CLUSTER_NAME must be defined" && exit 1)
TMP_DEPLOY=$(shell mktemp);\
FRONTEND_MI_CLIENT_ID=$(shell az deployment group show \
-g ${RESOURCE_GROUP} \
-n "hcp-${USER}-dev-infra" \
--query properties.outputs.frontend_mi_client_id.value);\
oc process -f ./deploy/aro-hcp-frontend.yml --local \
-p ARO_HCP_FRONTEND_IMAGE=${ARO_HCP_FRONTEND_IMAGE} \
-p FRONTEND_MI_CLIENT_ID="$${FRONTEND_MI_CLIENT_ID}" > "$${TMP_DEPLOY}";\
az aks command invoke --resource-group ${RESOURCE_GROUP} --name ${CLUSTER_NAME} --command "kubectl delete -f $$(basename $${TMP_DEPLOY})" --file "$${TMP_DEPLOY}"

.PHONY: all clean frontend-build frontend-build-container frontend-deploy frontend-undeploy lint test
.PHONY: all clean lint test
2 changes: 1 addition & 1 deletion frontend/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ ENV GOPATH="/go"
ENV PATH="${GOPATH}/bin:${PATH}"

WORKDIR /app
COPY . .
ADD archive.tar.gz .
RUN cd frontend && make frontend

FROM registry.access.redhat.com/ubi8/ubi-minimal:8.9-1161
Expand Down
60 changes: 59 additions & 1 deletion frontend/Makefile
Original file line number Diff line number Diff line change
@@ -1,8 +1,66 @@
SHELL = /bin/bash
COMMIT = $(shell git rev-parse --short=7 HEAD)$(shell [[ $$(git status --porcelain) = "" ]] || echo -dirty)
ARO_HCP_BASE_IMAGE ?= ${ARO_HCP_IMAGE_ACR}.azurecr.io
ARO_HCP_FRONTEND_IMAGE ?= $(ARO_HCP_BASE_IMAGE)/arohcpfrontend:$(COMMIT)

# for deploying frontend into private aks cluster via invoke command
# these values must be set
RESOURCE_GROUP ?=
CLUSTER_NAME ?=

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

clean:
rm -f aro-hcp-frontend

image:
pushd .. && git archive --output frontend/archive.tar.gz HEAD && popd
docker build --platform="linux/amd64" -f "./Dockerfile" -t ${ARO_HCP_FRONTEND_IMAGE} .
rm -f archive.tar.gz

deploy:
@test "${RESOURCE_GROUP}" != "" || (echo "RESOURCE_GROUP must be defined" && exit 1)
FRONTEND_MI_CLIENT_ID=$(shell az deployment group show \
-g ${RESOURCE_GROUP} \
-n "hcp-${USER}-dev-infra" \
--query properties.outputs.frontend_mi_client_id.value);\
oc process -f ./deploy/aro-hcp-frontend.yml --local \
-p ARO_HCP_FRONTEND_IMAGE=${ARO_HCP_FRONTEND_IMAGE} \
-p FRONTEND_MI_CLIENT_ID="$${FRONTEND_MI_CLIENT_ID}" | oc apply -f -

undeploy:
@test "${RESOURCE_GROUP}" != "" || (echo "RESOURCE_GROUP must be defined" && exit 1)
FRONTEND_MI_CLIENT_ID=$(shell az deployment group show \
-g ${RESOURCE_GROUP} \
-n "hcp-${USER}-dev-infra" \
--query properties.outputs.frontend_mi_client_id.value);\
oc process -f ./deploy/aro-hcp-frontend.yml --local \
-p ARO_HCP_FRONTEND_IMAGE=${ARO_HCP_FRONTEND_IMAGE} \
-p FRONTEND_MI_CLIENT_ID="$${FRONTEND_MI_CLIENT_ID}" | oc delete -f -

deploy-private:
@test "${RESOURCE_GROUP}" != "" && test "${CLUSTER_NAME}" != "" || (echo "RESOURCE_GROUP and CLUSTER_NAME must be defined" && exit 1)
TMP_DEPLOY=$(shell mktemp);\
FRONTEND_MI_CLIENT_ID=$(shell az deployment group show \
-g ${RESOURCE_GROUP} \
-n "hcp-${USER}-dev-infra" \
--query properties.outputs.frontend_mi_client_id.value);\
oc process -f ./deploy/aro-hcp-frontend.yml --local \
-p ARO_HCP_FRONTEND_IMAGE=${ARO_HCP_FRONTEND_IMAGE} \
-p FRONTEND_MI_CLIENT_ID="$${FRONTEND_MI_CLIENT_ID}" > "$${TMP_DEPLOY}";\
az aks command invoke --resource-group ${RESOURCE_GROUP} --name ${CLUSTER_NAME} --command "kubectl create -f $$(basename $${TMP_DEPLOY})" --file "$${TMP_DEPLOY}"

undeploy-private:
@test "${RESOURCE_GROUP}" != "" && test "${CLUSTER_NAME}" != "" || (echo "RESOURCE_GROUP and CLUSTER_NAME must be defined" && exit 1)
TMP_DEPLOY=$(shell mktemp);\
FRONTEND_MI_CLIENT_ID=$(shell az deployment group show \
-g ${RESOURCE_GROUP} \
-n "hcp-${USER}-dev-infra" \
--query properties.outputs.frontend_mi_client_id.value);\
oc process -f ./deploy/aro-hcp-frontend.yml --local \
-p ARO_HCP_FRONTEND_IMAGE=${ARO_HCP_FRONTEND_IMAGE} \
-p FRONTEND_MI_CLIENT_ID="$${FRONTEND_MI_CLIENT_ID}" > "$${TMP_DEPLOY}";\
az aks command invoke --resource-group ${RESOURCE_GROUP} --name ${CLUSTER_NAME} --command "kubectl delete -f $$(basename $${TMP_DEPLOY})" --file "$${TMP_DEPLOY}"

.PHONY: frontend clean image deploy undeploy deploy-private undeploy-private
File renamed without changes.

0 comments on commit 270da4a

Please sign in to comment.