Repository navigation
Expand file tree
/
Copy pathdeploy.sh
More file actions
executable file
·51 lines (40 loc) · 1.58 KB
/
Copy pathdeploy.sh
File metadata and controls
executable file
·51 lines (40 loc) · 1.58 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
#!/bin/bash
set -e
# Default to ttl.sh (an ephemeral, anonymous registry) for easiest deployment
REGISTRY=${1:-"ttl.sh"}
IMAGE_TAG=$(uuidgen | tr '[:upper:]' '[:lower:]' | head -c 8)
FRONTEND_IMAGE="${REGISTRY}/pwd-lookup-frontend-${IMAGE_TAG}:24h"
BACKEND_IMAGE="${REGISTRY}/pwd-lookup-backend-${IMAGE_TAG}:24h"
echo "Building frontend image: $FRONTEND_IMAGE"
docker build -t $FRONTEND_IMAGE -f frontend/Dockerfile.prod frontend/
echo "Building backend image: $BACKEND_IMAGE"
docker build -t $BACKEND_IMAGE -f backend/Dockerfile.prod .
echo "Pushing images to registry..."
docker push $FRONTEND_IMAGE
docker push $BACKEND_IMAGE
echo "Applying Kubernetes manifests..."
# Temporarily replace the image placeholders and apply
kubectl apply -f k8s/namespace.yaml
# Create a temporary directory for modified manifests
mkdir -p .k8s-tmp
cp k8s/backend.yaml .k8s-tmp/
cp k8s/frontend.yaml .k8s-tmp/
# Replace placeholders with actual image names
case "$(uname -s)" in
Darwin*)
sed -i "" "s|PWD_BACKEND_IMAGE|$BACKEND_IMAGE|g" .k8s-tmp/backend.yaml
sed -i "" "s|PWD_FRONTEND_IMAGE|$FRONTEND_IMAGE|g" .k8s-tmp/frontend.yaml
;;
*)
sed -i "s|PWD_BACKEND_IMAGE|$BACKEND_IMAGE|g" .k8s-tmp/backend.yaml
sed -i "s|PWD_FRONTEND_IMAGE|$FRONTEND_IMAGE|g" .k8s-tmp/frontend.yaml
;;
esac
kubectl apply -f k8s/mongodb.yaml
kubectl apply -f .k8s-tmp/backend.yaml
kubectl apply -f .k8s-tmp/frontend.yaml
kubectl apply -f k8s/ingress.yaml
# Clean up temp files
rm -rf .k8s-tmp
echo "Deployment complete! Waiting for pods to initialize..."
kubectl get pods -n pwd-lookup -w