# sync with github
git remote -v
git remote add upstream https://github.com/estarter/d-tools.git
git fetch upstream
git merge upstream/master
git remote rm upstreamThe aim of this project is to tackle a problem of "too long commands" in docker. It is a set of useful commands to deal with docker / docker-compose projects in a laconic way.
Check out usage example based on d-tools-example project (screenplay).
- Control sophisticated docker-compose project in a simple way
- Call it from any location
- Memorise your active docker-compose files and docker-compose project name
- Allows custom scripts execution before docker build process
dset- specify project name and docker-compose files..d-tool.config.jsonin local or home dir will be created.dbuild- prepare docker build context and build one, few or all images (wrapper for docker-compose build).dup- starts up the system (wrapper for docker-compose up)dps- shows running containers (wrapper for docker ps)ddown- removes and clean up the system (wrapper for docker-compose down)dstart- Start a set of docker containers or all containers (wrapper for docker start or docker-compose start)drestart- Restart a set of docker containers or all containers (wrapper for docker start or docker-compose start)dstop- Stop a set of docker containers or all running containers (wrapper for docker stop or docker-compose stop)dcleanup- remove all dangling images and volumes. It may save a lot of your HD.
dbash container- get a bash session inside the containerdlog container- prints out container's log using custom/usr/bin/dlogcommand. When you have a big zoo of technologies and containers, with different path conventions, it's useful to have a same command that shows log files (example).dclient container- run karaf's client command inside karaf containerddeploy -c container file.jar- deployfile.jartocontainerserver, i.e. copy to the deploy folder/dthat should be a symlink to actual deploy folder
Skip container parameter to use the same container:
dlog server
# server logs ...
dbash
# connects to server container
dlog
# server logs ...dbuild auto-discovers prebuild.sh scripts in any build/context folders defined in your docker-compose files
and execute it before running docker-compose build command.
That allows you to execute a custom actions just before docker-compose build command is called.
It's useful in non-trivial project to prepare docker build context automatically before building the image.
For example, you can run the build program in prebuild.sh (e.g. maven).
Try how it works in test project (see prebuild.sh example)
-hoptions in any script shows all available optiondupcommand would not recreate your containers on change. Usedocker rmanddcleanupto recreate a container.dbuildcommand by default would pull the image. It's could be annoying, but allows to avoid some silly mistakes.
Update python modules
# if PIP is not installed
sudo apt-get install python-setuptools python-dev build-essential
sudo easy_install pip
sudo pip install argcomplete PyYAMLMake it a git-submodule to your project.
git submodule add -b master https://github.com/estarter/d-tools.git
# add to the PATH variable to call the script from any location
echo "export PATH=$PATH:$(pwd)/d-tools" >> ~/.bashrcNote that PATH variable would only work for one project.
sudo pip install argcomplete
activate-global-python-argcomplete
echo ". $(pwd)/autocomplete.sh" >> ~/.bashrcsudo pip install argcomplete
# enable bash autocomplete supprot
echo 'autoload -Uz compinit bashcompinit' >> ~/.zshrc
echo 'compinit' >> ~/.zshrc
echo 'bashcompinit' >> ~/.zshrc
echo ". $(pwd)/autocomplete.sh" >> ~/.zshrc- write unit test for them; current test solution:
cp ddeploy ddeploy.py && pytest ddeploy.py ; rm ddeploy.py - automate build + PEP-check code
