-
Notifications
You must be signed in to change notification settings - Fork 9
Expand file tree
/
Copy pathsetup.sh
More file actions
executable file
·200 lines (167 loc) · 6.13 KB
/
setup.sh
File metadata and controls
executable file
·200 lines (167 loc) · 6.13 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
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
#!/bin/bash
# Document Engine on OrbStack with Kubernetes - Automated Setup Script
# This script automates the deployment of Document Engine on OrbStack
set -e
# Colors for output
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
NC='\033[0m' # No Color
# Print colored messages
print_info() {
echo -e "${GREEN}[INFO]${NC} $1"
}
print_warning() {
echo -e "${YELLOW}[WARNING]${NC} $1"
}
print_error() {
echo -e "${RED}[ERROR]${NC} $1"
}
print_section() {
echo ""
echo -e "${GREEN}========================================${NC}"
echo -e "${GREEN}$1${NC}"
echo -e "${GREEN}========================================${NC}"
}
# Check if a command exists
command_exists() {
command -v "$1" >/dev/null 2>&1
}
# Check prerequisites
check_prerequisites() {
print_section "Checking Prerequisites"
if ! command_exists orb; then
print_error "OrbStack is not installed. Please install it from https://orbstack.dev"
exit 1
fi
print_info "✓ OrbStack is installed"
if ! command_exists kubectl; then
print_error "kubectl is not installed. Install it with: brew install kubectl"
exit 1
fi
print_info "✓ kubectl is installed"
if ! command_exists helm; then
print_error "Helm is not installed. Install it with: brew install helm"
exit 1
fi
print_info "✓ Helm is installed"
# Check if Kubernetes is running
if ! kubectl cluster-info &> /dev/null; then
print_error "Kubernetes cluster is not accessible. Please enable Kubernetes in OrbStack."
exit 1
fi
print_info "✓ Kubernetes cluster is running"
}
# Install CloudNative-PG Operator
install_cloudnative_pg() {
print_section "Installing CloudNative-PG Operator"
helm repo add cnpg https://cloudnative-pg.github.io/charts 2>/dev/null || true
helm repo update
if helm list -n cnpg-system | grep -q cnpg; then
print_info "CloudNative-PG is already installed, skipping..."
else
print_info "Installing CloudNative-PG Operator..."
helm upgrade --install cnpg \
--namespace cnpg-system \
--create-namespace \
cnpg/cloudnative-pg
print_info "✓ CloudNative-PG Operator installed"
fi
}
# Install Nginx Ingress Controller
install_nginx_ingress() {
print_section "Installing Nginx Ingress Controller"
if kubectl get namespace ingress-nginx &> /dev/null; then
print_info "Nginx Ingress Controller is already installed, skipping..."
else
print_info "Installing Nginx Ingress Controller..."
kubectl apply -f https://raw.githubusercontent.com/kubernetes/ingress-nginx/controller-v1.8.1/deploy/static/provider/cloud/deploy.yaml
print_info "Waiting for Nginx Ingress Controller to be ready..."
kubectl -n ingress-nginx wait \
--for=condition=Available \
deployment/ingress-nginx-controller \
--timeout=300s
print_info "✓ Nginx Ingress Controller is ready"
fi
}
# Install Document Engine
install_document_engine() {
print_section "Installing Document Engine"
helm repo add nutrient https://pspdfkit.github.io/helm-charts 2>/dev/null || true
helm repo update
print_info "Installing Document Engine with Helm..."
# OrbStack-specific settings:
# - storageClass=local-path (OrbStack's default storage class)
# - host=document-engine.k8s.orb.local (OrbStack's DNS domain)
# - storage.size=128Mi (minimal size for local development)
helm upgrade --install \
--namespace document-engine \
--create-namespace \
document-engine nutrient/document-engine \
-f document-engine.values.yaml \
--set cloudNativePG.clusterSpec.storage.size=128Mi \
--set cloudNativePG.clusterSpec.storage.storageClass=local-path \
--set "ingress.hosts[0].host=document-engine.k8s.orb.local"
print_info "✓ Document Engine installation initiated"
}
# Wait for Document Engine to be ready
wait_for_document_engine() {
print_section "Waiting for Document Engine to be Ready"
print_info "This may take a few minutes..."
# Wait for database cluster to be ready
print_info "Waiting for database cluster..."
kubectl wait --for=condition=Ready \
cluster/document-engine-postgresql \
-n document-engine \
--timeout=300s 2>/dev/null || true
# Wait for Document Engine pods to be ready
print_info "Waiting for Document Engine pods..."
kubectl wait --for=condition=Ready \
pod -l app.kubernetes.io/name=document-engine \
-n document-engine \
--timeout=300s
print_info "✓ Document Engine is ready"
}
# Display access information
display_info() {
print_section "Installation Complete!"
echo ""
echo "Document Engine is now running on your OrbStack Kubernetes cluster."
echo ""
echo "Access Information:"
echo " API Endpoint: http://document-engine.k8s.orb.local"
echo " Dashboard: http://document-engine.k8s.orb.local/dashboard"
echo " Dashboard User: admin"
echo " Dashboard Pass: admin"
echo ""
echo "API Authentication:"
echo " Use header: Authorization: Token token=secret"
echo ""
echo "Test the installation:"
echo " curl http://document-engine.k8s.orb.local/healthcheck"
echo ""
echo "Upload a sample document:"
echo " curl --request POST \\"
echo " --url http://document-engine.k8s.orb.local/api/documents \\"
echo " --header 'Authorization: Token token=secret' \\"
echo " --form 'pdf-file-from-multipart=@sample.pdf' \\"
echo " --form 'instructions={\"parts\":[{\"file\":\"pdf-file-from-multipart\"}],\"actions\":[],\"output\":{\"type\":\"pdf\"}}'"
echo ""
echo "View logs:"
echo " kubectl logs -n document-engine -l app.kubernetes.io/name=document-engine"
echo ""
echo "For more information, see the README.md file."
echo ""
}
# Main installation flow
main() {
print_section "Document Engine on OrbStack - Setup"
check_prerequisites
install_cloudnative_pg
install_nginx_ingress
install_document_engine
wait_for_document_engine
display_info
}
# Run main function
main