Makefile for handle multiple docker-compose projects based on a directory structure and some files.
.
|-- Makefile
|-- preset.mk
|-- gitlab
| |-- .env
| |-- .desc
| `-- docker-compose.yml
|-- pgadmin
| |-- .env
| |-- .alias
| |-- .desc
| `-- docker-compose.yml
|-- postgres
| |-- .env
| |-- .alias
| |-- .desc
| |-- docker-compose.yml
| `-- init
| `-- init_gitlab.sh
`-- redis
|-- .env
|-- .desc
`-- docker-compose.yml
$ make [dirname|alias|preset]... [command]
or
$ make [command]
up
,upf
,build
,pull
,down
,start
,stop
,restart
,pause
,unpause
,ps
,logs
,logsf
,logs<int>
,logsf<int>
,top
up
executesup -d
.upf
executesup
.logsf
executeslogs -f
.logs<int>
executeslogs -n <int>
.logsf<int>
executeslogs -f -n <int>
.
do cmd="[any docker compose command]"
info
- Show directory name and description.
active
- Same as
$ make all ps | grep Up
.
- Same as
ls
- Show the directory name, alias, and description of all projects.
clean
- Remove
.dc_history
and.dc_latest
.
- Remove
Targets are executed sequentially. (Ref: GNU Make)
So...
$ make proj1 down proj2 pull proj3 up
This works as follows:
- Add
proj1
to the processing target - Execute
down
toproj1
- Add
proj2
to the processing target - Execute
pull
toproj1 & 2
- Add
proj3
to the processing target - Execute
up -d
toproj1 & 2 & 3
Define at the preset.mk
.
.PHONY: preset_name
preset_name: [dirname|alias|preset|command]...
.PHONY: preset1 preset2 preset3
preset1: proj1 proj3 proj5
preset2: proj2 proj3
preset3: preset1 preset2
preset3
means proj1 proj3 proj5 proj2
.
all
- All projects.
latest
- The project(s) that was operated last time. (Written in
.dc_latest
)
- The project(s) that was operated last time. (Written in
The directory containing docker-compose.yml
will detect as the docker compose project.
Strongly recommended setting the project name using COMPOSE_PROJECT_NAME
.
Write a short description used in ls
and info
commands.
Write a short name that can use as an alternative to the directory name.
To define presets.
A temporary file to record the current project being operated.
Log of executed commands except for ps
, logs
, logsf
and top
.