Skip to content

Commit

Permalink
Merge pull request Azure#84 from tonytheleg/fix-deployment-template
Browse files Browse the repository at this point in the history
updates to frontend deploy template, and to run as nonroot
  • Loading branch information
mjlshen authored Apr 30, 2024
2 parents 808bad7 + b91d8be commit e68ed63
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 2 deletions.
19 changes: 17 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,11 @@ COMMIT = $(shell git rev-parse --short=7 HEAD)$(shell [[ $$(git status --porcela
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

# There is currently no convenient way to run tests against a whole Go workspace
Expand All @@ -20,9 +25,19 @@ frontend-build-container:
docker build --platform="linux/amd64" -f "frontend/Dockerfile" -t ${ARO_HCP_FRONTEND_IMAGE} .

frontend-deploy:
oc process -f ./deploy/aro-hcp-frontend.yml -p ARO_HCP_FRONTEND_IMAGE=${ARO_HCP_FRONTEND_IMAGE} | oc apply -f -
oc process -f ./deploy/aro-hcp-frontend.yml -p ARO_HCP_FRONTEND_IMAGE=${ARO_HCP_FRONTEND_IMAGE} --local | oc apply -f -

frontend-undeploy:
oc process -f ./deploy/aro-hcp-frontend.yml -p ARO_HCP_FRONTEND_IMAGE=${ARO_HCP_FRONTEND_IMAGE} | oc delete -f -
oc process -f ./deploy/aro-hcp-frontend.yml -p ARO_HCP_FRONTEND_IMAGE=${ARO_HCP_FRONTEND_IMAGE} --local | oc delete -f -

frontend-deploy-private:
@test "${RESOURCE_GROUP}" != "" && test "${CLUSTER_NAME}" != "" || (echo "RESOURCE_GROUP and CLUSTER_NAME must be defined" && exit 1)
oc process -f ./deploy/aro-hcp-frontend.yml -p ARO_HCP_FRONTEND_IMAGE=${ARO_HCP_FRONTEND_IMAGE} --local > /tmp/deploy.yml
az aks command invoke --resource-group ${RESOURCE_GROUP} --name ${CLUSTER_NAME} --command "kubectl create -f deploy.yml" --file /tmp/deploy.yml

frontend-undeploy-private:
@test "${RESOURCE_GROUP}" != "" && test "${CLUSTER_NAME}" != "" || (echo "RESOURCE_GROUP and CLUSTER_NAME must be defined" && exit 1)
oc process -f ./deploy/aro-hcp-frontend.yml -p ARO_HCP_FRONTEND_IMAGE=${ARO_HCP_FRONTEND_IMAGE} --local > /tmp/deploy.yml
az aks command invoke --resource-group ${RESOURCE_GROUP} --name ${CLUSTER_NAME} --command "kubectl delete -f deploy.yml" --file /tmp/deploy.yml

.PHONY: frontend-build frontend-build-container frontend-deploy frontend-undeploy test lint clean
4 changes: 4 additions & 0 deletions deploy/aro-hcp-frontend.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@ parameters:
required: true

objects:
- apiVersion: v1
kind: Namespace
metadata:
name: ${NAMESPACE}
- apiVersion: apps/v1
kind: Deployment
metadata:
Expand Down
4 changes: 4 additions & 0 deletions frontend/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@ RUN cd frontend && make frontend

FROM registry.access.redhat.com/ubi8/ubi-minimal:8.9-1161

ENV USER_UID=1001 \
USER_NAME=frontend

COPY --from=builder /app/frontend/aro-hcp-frontend /usr/local/bin/
ENTRYPOINT ["aro-hcp-frontend"]
USER ${USER_UID}
EXPOSE 8443/tcp

0 comments on commit e68ed63

Please sign in to comment.