Giter Site home page Giter Site logo

macropygia / dc-multiple-project-makefile Goto Github PK

View Code? Open in Web Editor NEW
1.0 1.0 0.0 20 KB

Makefile for handle multiple docker-compose projects based on a directory structure and some files.

License: Apache License 2.0

Makefile 98.69% Shell 1.31%
docker docker-compose make makefile

dc-multiple-project-makefile's Introduction

dc-multiple-project-makefile

Makefile for handle multiple docker-compose projects based on a directory structure and some files.

animation

Typical structure

.
|-- 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

Usage

$ make [dirname|alias|preset]... [command]

or

$ make [command]

Commands

Use with dirname/alias/preset

  • up, upf, build, pull, down, start, stop, restart, pause, unpause, ps, logs, logsf, logs<int>, logsf<int>, top
    • up executes up -d .
    • upf executes up .
    • logsf executes logs -f .
    • logs<int> executes logs -n <int> .
    • logsf<int> executes logs -f -n <int> .
  • do cmd="[any docker compose command]"
  • info
    • Show directory name and description.

Use independently

  • active
    • Same as $ make all ps | grep Up.
  • ls
    • Show the directory name, alias, and description of all projects.
  • clean
    • Remove .dc_history and .dc_latest.

Tips

Targets are executed sequentially. (Ref: GNU Make)

So...

$ make proj1 down proj2 pull proj3 up

This works as follows:

  1. Add proj1 to the processing target
  2. Execute down to proj1
  3. Add proj2 to the processing target
  4. Execute pull to proj1 & 2
  5. Add proj3 to the processing target
  6. Execute up -d to proj1 & 2 & 3

Preset

Define at the preset.mk.

.PHONY: preset_name
preset_name: [dirname|alias|preset|command]...

Example

.PHONY: preset1 preset2 preset3
preset1: proj1 proj3 proj5
preset2: proj2 proj3
preset3: preset1 preset2

preset3 means proj1 proj3 proj5 proj2.

Built-in preset

  • all
    • All projects.
  • latest
    • The project(s) that was operated last time. (Written in .dc_latest)

Files

./*/docker-compose.yml

The directory containing docker-compose.yml will detect as the docker compose project.

./*/.env (Optional)

Strongly recommended setting the project name using COMPOSE_PROJECT_NAME.

./*/.desc (Optional)

Write a short description used in ls and info commands.

./*/.alias (Optional)

Write a short name that can use as an alternative to the directory name.

./preset.mk (Optional)

To define presets.

./.dc_latest

A temporary file to record the current project being operated.

./.dc_history

Log of executed commands except for ps , logs , logsf and top.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.