Helps to work with multiple git repositories and set custom build image process using docker-compose.yml
Modern services is a swarm of different interconnected micro-services where each micro-service is stored at individual repo. It can take a lot of time to setup this kind of environment. Docker-project helps to work with docker app stored in multiple git repositories and set custom build image process via docker-compose.yml
Case 1
git clone or pull for each microservice is a pain.
Let's say you have a microservice application which contains 5 microservices.
Each microservice is a small application on it's own, so you have 5 different git repositories for them.
Docker-compose is used tightly to make it all work together.
This means when you start work with the whole application, you will need to do git clone
5 times with proper parameters to a proper destination and so on. If you work in a team time to time you will need to do git pull
5 times. Git submodules are not convinient thing to use in this case.
Case 2
Custom build image process
Building docker appplications sometimes is not just a matter of running docker build
. There is no need to bring heavy development tools inside of your image in order to build applications. You split the process in two phases - building and packing in the image. You will have bash script or Makefile, so you need to store somewhere a command to build the image and be able to build all microservices in single call.
Using labels you can define metadata for any service in docker-compose.yml.
Where git repo link, branch, build and other commands are specified as labels for a service, docker-project will parse out that information and will be able to git clone or pull for each defined repo and run commands over the repositories.
docker-project
is able to run commands only over repos that have project_git label or build path.
By default docker-project
creates apps folder next to docker-compose.yml file. That path can be changes using parameter -a.
Works with docker-compose.yml version 2+
version: "2"
services:
users:
image: vendor/users
expose:
- 80
labels:
project.git: https://github.com/vendor/users.git # linking git repo
project.git.branch: cool-feature # custom branch, default is master
project.build: make # defining build command
project.custom1: echo __image__ # defining custom1 command
project.custom2: echo __image__ # defining custom2 command
Meta tags can be used in commands definitions as well as extra (-x
) parameter string:
__image__
- image name__service__
- service name
docker-project update
# first time it will create apps/vendor/users folder
# vendor/users is taken from git link
# unless build: parameters is specified
# apps/ is relative to yml fine and can be changed
# then run 'git clone' the repo localy
docker-project build -x dev
# runs 'make dev' at apps/vendor/users
# -x add anything to the end of command
docker-project update
# since repo alredy exists it runs just 'git pull'
docker-project custom
# runs `echo vendor/users`
docker-project shell -x git checkout master
# runs `git checkout master` over all registered repos
docker project management tool 0.0.5
Usage:
docker-project <command> <arguments>
Commands:
update - clones or pulls application source
shell - uses extra parameter to run shell command for each app
status - prints current services with repos and their commands
help - prints help
your_command - defined as label for the service (example: labels: project.test: make test)
Arguments:
Full name | Short | Default | Note
-----------------------------------------------------
--file -f docker-compose.yml Alternative config file
--apps -a apps Applications sources folder
--extra -x Extra parameters passed to command
curl -O -L https://github.com/webreactor/docker-project/releases/download/0.0.5/docker-project
chmod a+x docker-project
sudo mv docker-project /usr/local/bin/
Depenencies:
*php-cli
git clone https://github.com/webreactor/docker-project.git
make
sudo make install
Depenencies for build:
- php-cli
- php composer
- make
- php.ini phar.readonly = off