-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathstart
More file actions
executable file
·140 lines (123 loc) · 4.36 KB
/
start
File metadata and controls
executable file
·140 lines (123 loc) · 4.36 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
#!/bin/bash
DEBUG_MODE=false
DEBUG_PORT=15670
ENABLE_TELEMETRY=false
while getopts dg flag
do
case "${flag}" in
d) DEBUG_MODE=true;;
g) ENABLE_TELEMETRY=true;;
esac
done
CMD=""
if [ $DEBUG_MODE = true ]; then
CMD="debugpy --wait-for-client --listen 0.0.0.0:$DEBUG_PORT -m uvicorn app:app --host 0.0.0.0 --port 80 --reload"
fi
trap "echo -ne '\nstopping container...' && docker stop refinery-gateway > /dev/null 2>&1 && echo -ne '\t\t [done]\n'" EXIT
unameOut="$(uname -s)"
nameOut="$(whoami)"
if [ "$nameOut" == "jens" ]; then
unameOut="jens"
fi
case "${unameOut}" in
#special case for jens machine
jens*) HOST_IP=$(ip a | grep "inet " | grep -v 127.0.0.1 | tac | head -1 | grep -o -E "[0-9]+.[0-9]+.[0-9]+.[0-9]+" | head -1);;
Linux*) HOST_IP=$(ip a | grep "inet " | grep -v 127.0.0.1| head -1 | grep -o -E "[0-9]+.[0-9]+.[0-9]+.[0-9]+" | head -1);;
Darwin*) HOST_IP=$(ifconfig | grep "inet " | grep -v 127.0.0.1 | head -1 | grep -o -E "[0-9]+.[0-9]+.[0-9]+.[0-9]+" | head -1);;
esac
echo -ne 'stopping old container...'
docker stop refinery-gateway > /dev/null 2>&1
echo -ne '\t [done]\n'
IS_ARM64=""
currentArch="$(uname -m)"
if [ "$currentArch" == "arm64" ];
then
echo "architecture: arm64"
IS_ARM64="_arm64"
else
echo "architecture: $currentArch"
fi
DEV_SETUP_DIR=${PWD%/*}/dev-setup/
if [ ! -d "$DEV_SETUP_DIR" ]
then
DEV_SETUP_DIR=${PWD%/*/*}/dev-setup/
if [ ! -d "$DEV_SETUP_DIR" ]
then
echo "Can't find dev setup directory: $DEV_SETUP_DIR -> stopping"
exit 1
fi
fi
MINIO_ENDPOINT="http://$HOST_IP:7053"
INFERENCE_DIR=${DEV_SETUP_DIR}etc/inference/
LOG_DIR=${DEV_SETUP_DIR}etc/logs/
CONFIG_DIR=${PWD%/*}/dev-setup/etc/config/
if [ ! -d "$CONFIG_DIR" ]
then
CONFIG_DIR=${PWD%/*/*}/dev-setup/etc/config/
if [ ! -d "$CONFIG_DIR" ]
then
# to include volume for local development, use the dev-setup inference folder:
# alternative use manual logic with
# -v /path/to/dev-setup/config:/config \
echo "Can't find config directory: $CONFIG_DIR -> stopping"
exit 1
fi
fi
echo -ne 'building container...'
docker build -t graphql-dev -f dev.Dockerfile .
echo -ne '\t\t [done]\n'
echo -ne 'migrating db...\n'
docker run --rm \
--name refinery-gateway-migration \
-e POSTGRES=postgresql://postgres:kern@graphql-postgres:5432 \
--mount type=bind,source="$(pwd)"/,target=/app \
--network dev-setup_default \
--entrypoint /usr/local/bin/alembic \
graphql-dev upgrade head
echo -ne 'migration done\n'
echo -ne 'starting...'
docker run -d --rm \
--name refinery-gateway \
-p $DEBUG_PORT:$DEBUG_PORT \
-p 7051:80 \
-e AC_EXEC_ENV_IMAGE=registry.dev.kern.ai/code-kern-ai/refinery-ac-exec-env:dev$IS_ARM64 \
-e LF_EXEC_ENV_IMAGE=registry.dev.kern.ai/code-kern-ai/refinery-lf-exec-env:dev$IS_ARM64 \
-e ML_EXEC_ENV_IMAGE=registry.dev.kern.ai/code-kern-ai/refinery-ml-exec-env:dev$IS_ARM64 \
-e LF_NETWORK=dev-setup_default \
-e S3_ENDPOINT="http://$HOST_IP:7053" \
-e S3_ENDPOINT_LOCAL=object-storage:9000 \
-e S3_ACCESS_KEY=kern \
-e S3_SECRET_KEY=r6ywtR33!DMlaL*SUUdy \
-e S3_USE_SSL=0 \
-e WS_NOTIFY_ENDPOINT=http://refinery-websocket:8080 \
-e POSTGRES=postgresql://postgres:kern@graphql-postgres:5432 \
-e UPDATER=http://refinery-updater:80 \
-e NEURAL_SEARCH=http://refinery-neural-search:80 \
-e MODEL_PROVIDER=http://refinery-model-provider:80 \
-e WEAK_SUPERVISION=http://refinery-weak-supervisor:80 \
-e EMBEDDING_SERVICE=http://refinery-embedder:80 \
-e TOKENIZER=http://refinery-tokenizer:80 \
-e COGNITION_GATEWAY=http://cognition-gateway:80 \
-e KRATOS_ADMIN_URL=http://kratos:4434 \
-e TASK_MASTER=http://cognition-task-master:80 \
-e INFERENCE_DIR=$INFERENCE_DIR \
-e SECRET_KEY=default \
-e POSTGRES_POOL_USE_LIFO=x \
-e KERN_S3_ENDPOINT=${MINIO_ENDPOINT} \
-e SMTP_HOST=mailhog \
-e SMTP_PORT=1025 \
-e ENABLE_TELEMETRY=$ENABLE_TELEMETRY \
-e PYDEVD_DISABLE_FILE_VALIDATION=1 \
-e INVITE_PAGE_URL=http://localhost:4455/auth/invite \
-v "$INFERENCE_DIR":/inference \
-v "$LOG_DIR":/logs \
-v "$CONFIG_DIR":/config \
--mount type=bind,source="$(pwd)"/,target=/app \
-v /var/run/docker.sock:/var/run/docker.sock \
--network dev-setup_default \
graphql-dev $CMD > /dev/null 2>&1
echo -ne '\t\t\t [done]\n'
if [ $DEBUG_MODE = true ]; then
echo -e "\033[0;33muse VSCode Debugger (Python Debugger: refinery-gateway) to start the service\033[0m"
fi
docker logs -f refinery-gateway \