-
Notifications
You must be signed in to change notification settings - Fork 38
Expand file tree
/
Copy pathMakefile.staging
More file actions
117 lines (98 loc) · 5.68 KB
/
Makefile.staging
File metadata and controls
117 lines (98 loc) · 5.68 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
# Makefile for Azure Kubernetes Service (AKS) Deployment
build-and-push-backend:
# Build agentex-backend image for amd64 linux
docker buildx build --platform=linux/amd64 --load -f Dockerfile -t agentex-backend:latest .
docker tag agentex-backend:latest sgpimages.azurecr.io/agentex-backend:latest
docker push sgpimages.azurecr.io/agentex-backend:latest
# Build temporal-worker image for amd64 linux
docker buildx build --platform=linux/amd64 --load -f Dockerfile.temporal.worker -t agentex-worker:latest .
docker tag agentex-worker:latest sgpimages.azurecr.io/agentex-worker:latest
docker push sgpimages.azurecr.io/agentex-worker:latest
# Build and push backend images with custom tag
# Usage: make build-and-push-backend-tagged TAG=v1.2.3
build-and-push-backend-tagged:
@if [ -z "$(TAG)" ]; then \
echo "Error: TAG is not defined. Please provide a tag for the images."; \
echo "Usage: make build-and-push-backend-tagged TAG=\"your_tag_name\""; \
exit 1; \
fi
# Build agentex-backend image for amd64 linux
docker buildx build --platform=linux/amd64 --load -f Dockerfile -t agentex-backend:$(TAG) .
docker tag agentex-backend:$(TAG) sgpimages.azurecr.io/agentex-backend:$(TAG)
docker push sgpimages.azurecr.io/agentex-backend:$(TAG)
# Build temporal-worker image for amd64 linux
docker buildx build --platform=linux/amd64 --load -f Dockerfile.temporal.worker -t agentex-worker:$(TAG) .
docker tag agentex-worker:$(TAG) sgpimages.azurecr.io/agentex-worker:$(TAG)
docker push sgpimages.azurecr.io/agentex-worker:$(TAG)
build-and-push-web:
cd ../agentex-web && \
docker buildx build --platform=linux/amd64 --load -f Dockerfile -t agentex-web:latest . && \
docker tag agentex-web:latest sgpimages.azurecr.io/agentex-web:latest && \
docker push sgpimages.azurecr.io/agentex-web:latest && \
cd -
# Command to build and push images to Azure Container Registry
build-and-push-all: build-and-push-backend build-and-push-web
# Command to deploy using Helm
deploy:
# Make sure you're connected to the right AKS cluster
@echo "Verifying connection to AKS cluster..."
kubectl config use-context sgpaz90011207k8s
@echo "Deploying with Helm..."
helmfile -f charts/helmfile.staging.yaml apply
port-forward:
kubectl config use-context sgpaz90011207k8s
(kubectl port-forward svc/temporal-web --namespace temporal 3000:8080 &)
@echo "Temporal Web service port-forward running in the background."
(kubectl port-forward service/agentex 5003:80 &)
@echo "Agentex service port-forward running in the background."
(kubectl port-forward service/agentex-web 3001:80 &)
@echo "Agentex Web service port-forward running in the background."
# Command to run full deployment to AKS
setup: deploy port-forward
# # Command to stop and remove all services
uninstall:
kubectl config use-context sgpaz90011207k8s
helm uninstall agentex agentex-web redis
# # Command to create a new Alembic migration
# migration:
# @echo "Starting PostgreSQL migration process..."
# # Check if a migration name (NAME) is provided
# @if [ -z "$(NAME)" ]; then \
# echo "Error: NAME is not defined. Please provide a name for the migration."; \
# exit 1; \
# fi
# kubectl config use-context sgpaz90011207k8s
# @echo "Running Alembic upgrade to the latest version in the agentex pod..."
# # Upgrade the database schema to the latest version inside the Kubernetes cluster
# kubectl exec -it $(shell kubectl get pods --selector=app.kubernetes.io/name=agentex -o jsonpath='{.items[0].metadata.name}') -- sh -c "cd /app/database/migrations && alembic upgrade head"
# @echo "Generating a new Alembic migration inside the agentex pod..."
# # Generate the migration inside the pod, using the PostgreSQL database
# kubectl exec -it $(shell kubectl get pods --selector=app.kubernetes.io/name=agentex -o jsonpath='{.items[0].metadata.name}') -- sh -c "cd /app/database/migrations && alembic revision --autogenerate -m '$(NAME)'"
# @echo "Copying the generated migration file to the local project..."
# # Copy the generated migration file from the pod to your local directory
# POD_MIGRATION_FILE=$$(kubectl exec $(shell kubectl get pods --selector=app.kubernetes.io/name=agentex -o jsonpath='{.items[0].metadata.name}') -- sh -c "ls /app/database/migrations/alembic/versions/*.py | sort | tail -n 1"); \
# FILE_NAME=$$(basename $$POD_MIGRATION_FILE); \
# kubectl cp $(shell kubectl get pods --selector=app.kubernetes.io/name=agentex -o jsonpath='{.items[0].metadata.name}'):$$POD_MIGRATION_FILE ./database/migrations/alembic/versions/$$FILE_NAME
# @echo "Migration generation completed and copied to the local machine."
# clean-db:
# @echo "Dropping and recreating the database..."
# kubectl config use-context sgpaz90011207k8s
# kubectl exec -it $(shell kubectl get pods --selector=app.kubernetes.io/name=agentex-postgres -o jsonpath='{.items[0].metadata.name}') -- psql -U postgres -c "DROP DATABASE IF EXISTS agentex;"
# kubectl exec -it $(shell kubectl get pods --selector=app.kubernetes.io/name=agentex-postgres -o jsonpath='{.items[0].metadata.name}') -- psql -U postgres -c "CREATE DATABASE agentex;"
# @echo "Database reset completed."
# # Command to log in to Azure Container Registry (add before building if needed)
# acr-login:
# az acr login --name sgpimages
# # Command to create Azure Kubernetes Secret for Container Registry
# create-registry-secret:
# kubectl config use-context sgpaz90011207k8s
# kubectl create secret docker-registry sgpimages-registry-credentials \
# --docker-server=sgpimages.azurecr.io \
# --docker-username=$(ACR_USERNAME) \
# --docker-password=$(ACR_PASSWORD) \
# --docker-email=$(ACR_EMAIL)
# # Command to check AKS connection
# check-aks:
# kubectl config use-context sgpaz90011207k8s
# kubectl get nodes
# kubectl get pods --all-namespaces