-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrun.sh
executable file
·59 lines (49 loc) · 1.54 KB
/
run.sh
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
#!/bin/bash
# Exit on error
set -e
# Container options
PORT_SERVING="8000"
PORT_STREAMLIT="8501"
TAG="latest"
NAME_SERVING="ift6758-serving"
NAME_STREAMLIT="ift6758-streamlit"
NETWORK_NAME="ift6758-network"
# Colors for the terminal
YELLOW='\033[1;33m'
PURPLE='\033[0;35m'
GREEN='\033[0;32m'
NO_COLOR='\033[0m'
# Load .env file if it exists
# Allows to set the WANDB_API_KEY and WANDB_ORG without exposing them in the script
if [ -f .env ] ; then
echo -e "${PURPLE}Loading environment variables from .env file${NO_COLOR}"
export $(cat .env | xargs)
fi
echo -e "${YELLOW}Stop previous docker containers (if any)${NO_COLOR}"
docker stop ${NAME_SERVING} || true
docker stop ${NAME_STREAMLIT} || true
echo -e "${YELLOW}Create docker network (if it doesn't exist)${NO_COLOR}"
docker network create ${NETWORK_NAME} || true
echo -e "${YELLOW}Run the docker containers${NO_COLOR}"
docker run \
--rm \
-d \
-p ${PORT_SERVING}:8000 \
-e WANDB_API_KEY=${WANDB_API_KEY} \
-e WANDB_ORG=${WANDB_ORG} \
--network ${NETWORK_NAME} \
--name ${NAME_SERVING} \
ift6758/serving:${TAG}
docker run \
--rm \
-d \
-p ${PORT_STREAMLIT}:8501 \
-e GAME_CLIENT_HOST="${NAME_SERVING}" \
-e GAME_CLIENT_PORT=${PORT_SERVING} \
-e SERVING_CLIENT_HOST="${NAME_SERVING}" \
-e SERVING_CLIENT_PORT=${PORT_SERVING} \
--network ${NETWORK_NAME} \
--name ${NAME_STREAMLIT} \
ift6758/streamlit:${TAG}
echo -e "${GREEN}Serving the model at http://localhost:${PORT_SERVING}${NO_COLOR}"
echo -e "${GREEN}Streamlit app running at http://localhost:${PORT_STREAMLIT}${NO_COLOR}"