Skip to content

Instantly share code, notes, and snippets.

@milushov
Created November 28, 2023 18:55
Show Gist options
  • Save milushov/11da0cd8122ef70304ef977277931158 to your computer and use it in GitHub Desktop.
Save milushov/11da0cd8122ef70304ef977277931158 to your computer and use it in GitHub Desktop.
up.sh
#!/bin/bash
# Don't forget chmod +x up.sh
# Installation:
# brew install jq
#
# Define function in ~/.zshrc
# container_name() {
# docker ps --format "{{.Names}}" | grep "app-1"
# }
# alias up="~/up.sh \$(container_name)"
if [ -z "$1" ]; then
echo "No projects on air"
else
CONTAINER_WORKING_DIR=$(docker inspect -f '{{json .Config.Labels}}' $1 | jq -r '.["com.docker.compose.project.working_dir"]')
if [ -z "$CONTAINER_WORKING_DIR" ]; then
echo "Error retrieving working directory. Exiting."
exit 1
fi
cd "$CONTAINER_WORKING_DIR"
echo "🔴 Shutting down the $(basename `pwd`).."
make down
cd -
fi
echo "🟢 Running up $(basename `pwd`).."
make up
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment