Automated scripts for deployment
This commit is contained in:
parent
a1fcababc0
commit
d0be1db5a3
1
.gitignore
vendored
1
.gitignore
vendored
@ -108,3 +108,4 @@ venv.bak/
|
||||
/data/*
|
||||
!/data/.gitkeep
|
||||
*.save*
|
||||
*.envsubst
|
||||
|
@ -1,20 +1,47 @@
|
||||
#!/usr/bin/env bash
|
||||
cd $(cd -P -- "$(dirname -- "$0")" && pwd -P)
|
||||
|
||||
if [[ -n "$1" ]]; then
|
||||
result=$(docker network ls)
|
||||
if [[ "$result" == *" $1 "* ]]; then
|
||||
echo "Adding gpu-jupyter to the swarm in the network $1."
|
||||
export JUPYTER_NETWORK=$1
|
||||
# echo $JUPYTER_NETWORK
|
||||
docker-compose -f docker-compose-swarm.yml build
|
||||
docker-compose -f docker-compose-swarm.yml push
|
||||
# docker stack deploy --compose-file docker-compose-swarm.yml gpu
|
||||
else
|
||||
echo "Could not find network $1. Please provide a valid docker network."
|
||||
fi
|
||||
else
|
||||
echo "Usage: $0 network"
|
||||
echo "Please set the network"
|
||||
# Fetching port and network as input
|
||||
PORT=8888
|
||||
while [[ "$#" -gt 0 ]]; do case $1 in
|
||||
-p|--port) PORT="$2"; shift;;
|
||||
-n|--network) NETWORK="$2"; shift;;
|
||||
# -u|--uglify) uglify=1;;
|
||||
*) echo "Unknown parameter passed: $1"; exit 1;;
|
||||
esac; shift; done
|
||||
|
||||
# Check if arguments are valid
|
||||
if [[ $PORT != [0-9][0-9][0-9][0-9]* ]]; then
|
||||
echo "Given port is not valid."
|
||||
echo "Usage: $0 -p [port] -n [docker-network] # port must be an integer with 4 or more digits."
|
||||
exit 21
|
||||
fi
|
||||
|
||||
if [[ $NETWORK == "" ]]; then
|
||||
echo "No docker network was provided to which this gpu-jupyter should be added to."
|
||||
echo "Usage: $0 -p [port] -n [docker-network] # port must be an integer with 4 or more digits."
|
||||
exit 22
|
||||
fi
|
||||
result=$(docker network ls)
|
||||
if [[ "$result" != *" $NETWORK "* ]]; then
|
||||
echo "Could not find network $NETWORK. Please provide a valid docker network."
|
||||
echo "Please select a network:"
|
||||
docker network ls
|
||||
exit 23
|
||||
fi
|
||||
|
||||
# starting in swarm
|
||||
echo "Adding gpu-jupyter to the swarm in the network $NETWORK on port $PORT."
|
||||
export JUPYTER_PORT=$PORT
|
||||
export JUPYTER_NETWORK=$NETWORK
|
||||
# echo $JUPYTER_NETWORK
|
||||
envsubst < docker-compose-swarm.yml > .docker-compose-swarm.yml.envsubst
|
||||
docker-compose -f .docker-compose-swarm.yml.envsubst build
|
||||
docker-compose -f .docker-compose-swarm.yml.envsubst push
|
||||
docker stack deploy --compose-file .docker-compose-swarm.yml.envsubst gpu
|
||||
rm .docker-compose-swarm.yml.envsubst
|
||||
|
||||
echo
|
||||
echo "Added gpu-jupyter to docker swarm $NETWORK on port $JUPYTER_PORT."
|
||||
echo "See 'docker service ps gpu_gpu-jupyter' for status info."
|
||||
echo "See 'docker service logs -f gpu_gpu-jupyter' for logs."
|
||||
|
@ -4,7 +4,7 @@ services:
|
||||
image: 127.0.0.1:5001/gpu-jupyter
|
||||
build: ./src/
|
||||
ports:
|
||||
- 8848:8888
|
||||
- $JUPYTER_PORT:8888
|
||||
volumes:
|
||||
- ./data:/home/jovyan/work
|
||||
environment:
|
||||
|
@ -4,7 +4,7 @@ services:
|
||||
image: 127.0.0.1:5001/gpu-jupyter
|
||||
build: ./src/
|
||||
ports:
|
||||
- 8848:8888
|
||||
- ${JUPYTER_PORT}:8888
|
||||
volumes:
|
||||
- ./data:/home/jovyan/work
|
||||
environment:
|
||||
@ -13,16 +13,3 @@ services:
|
||||
# enable sudo permissions
|
||||
user:
|
||||
"root"
|
||||
deploy:
|
||||
placement:
|
||||
constraints: [node.hostname == data-science]
|
||||
resources:
|
||||
limits:
|
||||
cpus: "4"
|
||||
memory: 8G
|
||||
replicas: 1
|
||||
update_config:
|
||||
parallelism: 2
|
||||
delay: 10s
|
||||
restart_policy:
|
||||
condition: on-failure
|
||||
|
@ -1,4 +1,5 @@
|
||||
#!/usr/bin/env bash
|
||||
cd $(cd -P -- "$(dirname -- "$0")" && pwd -P)
|
||||
|
||||
docker stack rm gpu_gpu-jupyter
|
||||
echo "Removing gpu-jupyter from docker swarm."
|
||||
docker stack rm gpu
|
||||
|
@ -1,4 +1,27 @@
|
||||
#!/usr/bin/env bash
|
||||
cd $(cd -P -- "$(dirname -- "$0")" && pwd -P)
|
||||
|
||||
# Fetching port and network as input
|
||||
PORT=8888
|
||||
while [[ "$#" -gt 0 ]]; do case $1 in
|
||||
-p|--port) PORT="$2"; shift;;
|
||||
# -u|--uglify) uglify=1;;
|
||||
*) echo "Unknown parameter passed: $1"; exit 1;;
|
||||
esac; shift; done
|
||||
|
||||
# Check if arguments are valid
|
||||
if [[ $PORT != [0-9][0-9][0-9][0-9]* ]]; then
|
||||
echo "Given port is not valid."
|
||||
echo "Usage: $0 -p [port] -n [docker-network] # port must be an integer with 4 or more digits."
|
||||
exit 21
|
||||
fi
|
||||
|
||||
# starting in docker-compose
|
||||
echo "Starting gpu-jupyter via docker-compose on port $PORT."
|
||||
export JUPYTER_PORT=$PORT
|
||||
|
||||
# echo $JUPYTER_PORT
|
||||
docker-compose up --build -d
|
||||
echo
|
||||
echo "Started gpu-jupyter via docker-compose on port $JUPYTER_PORT."
|
||||
echo "See docker-compose logs -f for logs."
|
||||
|
@ -1,4 +1,6 @@
|
||||
#!/usr/bin/env bash
|
||||
cd $(cd -P -- "$(dirname -- "$0")" && pwd -P)
|
||||
|
||||
# Export default port to make compose file valid.
|
||||
export JUPYTER_PORT=8888
|
||||
docker-compose down
|
||||
|
Loading…
Reference in New Issue
Block a user