Created
November 28, 2023 18:55
-
-
Save milushov/11da0cd8122ef70304ef977277931158 to your computer and use it in GitHub Desktop.
up.sh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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