Skip to content

Instantly share code, notes, and snippets.

@kryakozyablik
Last active January 10, 2019 13:57
Show Gist options
  • Save kryakozyablik/87093868bc0237a552414580b897a76a to your computer and use it in GitHub Desktop.
Save kryakozyablik/87093868bc0237a552414580b897a76a to your computer and use it in GitHub Desktop.
Run docker-compose for project

Install for Mac Os

make directory if not exists

mkdir ~/bin

add ~/bin to executable path

echo 'PATH=~/bin:$PATH' >> ~/.bash_profile

copy file ds to ~/bin and set executable chmod

chmod +x ~/bin/ds

If yours project dir not in ~/project set DS_PROJECT_DIR env. Then restart bash session

echo 'export DS_PROJECT_DIR={YOUR_PROJECT_DIR}' >> ~/.bash_profile

Usage

run ds {project_name} to start composer for this project

after start you will be logged in for project's php container

write exit to exit from container :)

if [[ -z "${DS_PROJECT_DIR}" ]]; then
PROJECT_DIR=~/projects
else
PROJECT_DIR="${DS_PROJECT_DIR}"
fi
for d in $PROJECT_DIR/* ; do
DOCKER_COMPOSE_DIR="$d""/docker"
FILE="$d""/docker/docker-compose.yaml"
if [ -f $FILE ]; then
echo $FILE
cd $d && docker-compose stop
fi
done
cd $PROJECT_DIR/$1 && docker-compose up -d && docker-compose exec php bash
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment