deploy
status, install globally, rename run
This commit is contained in:
parent
86785b6aea
commit
ebb763518a
2
Makefile
2
Makefile
@ -4,7 +4,7 @@ dev_install:
|
|||||||
ln -s $(PWD)/abra ~/.local/bin
|
ln -s $(PWD)/abra ~/.local/bin
|
||||||
|
|
||||||
install:
|
install:
|
||||||
install abra $(HOME)/.local/bin/abra
|
install abra /usr/bin/abra
|
||||||
|
|
||||||
get_yq:
|
get_yq:
|
||||||
wget https://github.com/mikefarah/yq/releases/download/3.3.2/yq_linux_amd64 && \
|
wget https://github.com/mikefarah/yq/releases/download/3.3.2/yq_linux_amd64 && \
|
||||||
|
23
abra
23
abra
@ -10,7 +10,7 @@ sub_help(){
|
|||||||
echo "Usage: $PROGRAM_NAME <subcommand> [options]"
|
echo "Usage: $PROGRAM_NAME <subcommand> [options]"
|
||||||
echo ""
|
echo ""
|
||||||
echo "Subcommands:"
|
echo "Subcommands:"
|
||||||
echo " service_run SERVICE [CMD] run a command in the specified service's container"
|
echo " run SERVICE [CMD] run a command in the specified service's container"
|
||||||
echo " secret_generate SECRET VERSION [CMD] generate a secret, store it in pass & as a Docker secret"
|
echo " secret_generate SECRET VERSION [CMD] generate a secret, store it in pass & as a Docker secret"
|
||||||
echo " deploy [COMPOSE_FILE] let 'em rip"
|
echo " deploy [COMPOSE_FILE] let 'em rip"
|
||||||
echo " logs SERVICE tail logs from a deployed service"
|
echo " logs SERVICE tail logs from a deployed service"
|
||||||
@ -33,10 +33,15 @@ sub_secret_generate(){
|
|||||||
>(pass insert "hosts/autonomic-swarm/${STACK_NAME}/${SECRET}" -m)
|
>(pass insert "hosts/autonomic-swarm/${STACK_NAME}/${SECRET}" -m)
|
||||||
}
|
}
|
||||||
|
|
||||||
sub_service_run(){
|
sub_run(){
|
||||||
SERVICE=$1
|
SERVICE=$1
|
||||||
SH=${2:-/bin/sh}
|
SH=${2:-/bin/sh}
|
||||||
|
|
||||||
|
if [ -z "$SERVICE" ]; then
|
||||||
|
echo "Usage: $PROGRAM_NAME run SERVICE [CMD]"
|
||||||
|
exit
|
||||||
|
fi
|
||||||
|
|
||||||
CONTAINER=$(docker container ls --format "table {{.ID}},{{.Names}}" \
|
CONTAINER=$(docker container ls --format "table {{.ID}},{{.Names}}" \
|
||||||
| grep "${STACK_NAME}_${SERVICE}" | cut -d',' -f1)
|
| grep "${STACK_NAME}_${SERVICE}" | cut -d',' -f1)
|
||||||
|
|
||||||
@ -46,15 +51,17 @@ sub_service_run(){
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
docker exec -it "$CONTAINER" "$SH"
|
docker exec -it "$CONTAINER" "$SH"
|
||||||
|
|
||||||
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
sub_deploy (){
|
sub_deploy (){
|
||||||
COMPOSE=${1:-compose.yml}
|
COMPOSE=${1:-compose.yml}
|
||||||
|
|
||||||
echo "About to deploy:"
|
echo "About to deploy:"
|
||||||
echo "Compose: $(tput setaf 3)${PWD}/${COMPOSE}$(tput sgr0)"
|
echo " Compose: $(tput setaf 3)${PWD}/${COMPOSE}$(tput sgr0)"
|
||||||
echo "Domain: $(tput setaf 2)${DOMAIN}$(tput sgr0)"
|
echo " Domain: $(tput setaf 2)${DOMAIN}$(tput sgr0)"
|
||||||
echo "Stack: $(tput setaf 1)${STACK_NAME}$(tput sgr0)"
|
echo " Stack: $(tput setaf 1)${STACK_NAME}$(tput sgr0)"
|
||||||
|
|
||||||
read -rp "Continue? (y/[n])? " choice
|
read -rp "Continue? (y/[n])? " choice
|
||||||
|
|
||||||
@ -64,7 +71,11 @@ sub_deploy (){
|
|||||||
* ) return;;
|
* ) return;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
docker stack deploy -c "$COMPOSE" "$STACK_NAME"
|
if docker stack deploy -c "$COMPOSE" "$STACK_NAME"; then
|
||||||
|
echo "$(tput setaf 2)Yay! App should be available at https://${DOMAIN}$(tput sgr0)"
|
||||||
|
else
|
||||||
|
echo "$(tput setaf 1)Oh no! Something went wrong 😕 Check errors above$(tput sgr0)"
|
||||||
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
sub_logs (){
|
sub_logs (){
|
||||||
|
Loading…
Reference in New Issue
Block a user