Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move frontend-specific make targets to frontend/Makefile #109

Merged
merged 1 commit into from
May 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.