diff --git a/Makefile b/Makefile index 84c47a3be..2a51d4a9d 100644 --- a/Makefile +++ b/Makefile @@ -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 @@ -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 diff --git a/frontend/Dockerfile b/frontend/Dockerfile index 8177a221f..9a617d924 100644 --- a/frontend/Dockerfile +++ b/frontend/Dockerfile @@ -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 diff --git a/frontend/Makefile b/frontend/Makefile index 4e912c216..aca8a9dfb 100644 --- a/frontend/Makefile +++ b/frontend/Makefile @@ -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 diff --git a/deploy/aro-hcp-frontend.yml b/frontend/deploy/aro-hcp-frontend.yml similarity index 100% rename from deploy/aro-hcp-frontend.yml rename to frontend/deploy/aro-hcp-frontend.yml