Last active
July 16, 2024 03:12
-
-
Save Max95Cohen/0cfafd308fab1c2e4e32e4a69fe6b5e0 to your computer and use it in GitHub Desktop.
.bashrc doker-compose bash script
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
alias compose-ps="docker ps --format 'table {{ .Names }}\t{{ .Status }}\t{{ .Label \"com.docker.compose.project\" }}\t{{ .Label \"com.docker.compose.service\" }}\t{{ .Label \"com.docker.compose.project.working_dir\" }}'" | |
alias dps="docker ps -a --format 'ID: {{.ID}}\nNames: {{.Names}}\nProject: {{.Label \"com.docker.compose.project\"}}\nPorts: {{.Ports}}\nStatus: {{.Status}}\n'" | |
dc() { | |
project=$1 | |
container=$2 | |
check=echo $project | grep "laravel" | |
if [ -z $check ]; then | |
path="frontend" | |
if [ -z $container ]; then | |
container="phalcon" | |
path="api" | |
fi | |
if [ ! -z $1 ] && [ $1 != "dev" ]; then | |
project=echo $1 | tr '[:lower:]' '[:upper:]' | |
fi | |
else | |
container="laravel" | |
path="frontend" | |
project="" | |
fi | |
path_=$path | |
if [ -z $project ]; then | |
path=~/$path | |
else | |
if [ $1 == 'dev' ]; then | |
path="/var/www/$path" | |
else | |
path="/var/www/builds/$path/$project" | |
fi | |
fi | |
cd $path | |
if [ ! -z $project ]; then | |
project="-p ${project}_$path_" | |
fi | |
docker-compose $project exec $container bash | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment