{"id":13416440,"url":"https://github.com/CtripCloud/docker-make","last_synced_at":"2025-03-14T23:31:51.643Z","repository":{"id":57423287,"uuid":"61364522","full_name":"ctripcloud/docker-make","owner":"ctripcloud","description":"build,tag,and push a bunch of related docker images via a single command","archived":false,"fork":false,"pushed_at":"2019-11-22T08:32:26.000Z","size":70,"stargazers_count":98,"open_issues_count":3,"forks_count":21,"subscribers_count":9,"default_branch":"master","last_synced_at":"2025-01-10T02:37:14.334Z","etag":null,"topics":["docker-image","dockerfile","multitple-docker-images"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ctripcloud.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2016-06-17T10:01:45.000Z","updated_at":"2024-09-22T06:28:51.000Z","dependencies_parsed_at":"2022-09-05T12:30:27.414Z","dependency_job_id":null,"html_url":"https://github.com/ctripcloud/docker-make","commit_stats":null,"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ctripcloud%2Fdocker-make","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ctripcloud%2Fdocker-make/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ctripcloud%2Fdocker-make/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ctripcloud%2Fdocker-make/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ctripcloud","download_url":"https://codeload.github.com/ctripcloud/docker-make/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243663516,"owners_count":20327300,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["docker-image","dockerfile","multitple-docker-images"],"created_at":"2024-07-30T21:00:58.869Z","updated_at":"2025-03-14T23:31:46.632Z","avatar_url":"https://github.com/ctripcloud.png","language":"Python","readme":"# docker-make\n[![Build Status](https://travis-ci.org/CtripCloud/docker-make.svg?branch=master)](https://travis-ci.org/CtripCloud/docker-make) [![Docker Pulls](https://img.shields.io/docker/pulls/jizhilong/docker-make.svg?maxAge=2592000)]()\n\n`docker-make` is a command line tool inspired by [docker-compose](https://www.docker.com/products/docker-compose), while `docker-compose`\nfocus on managing the lifecycle of a bunch of related docker containers, `docker-make` aimes at simplify and automate the procedure of\nbuilding,tagging,and pusing a bunch of related docker images.\n\n## table of contents\n- [Install](#installation)\n  * [via pip](#install-via-pip)\n  * [via alias to docker run](#instanll-via-alias-to-docker-run)\n- [Quickstart](#quickstart)\n- [Use Cases](#typical-use-cases)\n  * [single image-tag,push on condition](#single-image-tagpush-on-condition)\n  * [two images-one for compile, one for deployment](#two-images-one-for-compile-one-for-deployment)\n  * [two images-one for deploy, one for unit tests](#two-images-one-for-deploy-one-for-unit-tests)\n  * [several images-one as base with tools, others for different applications](#several-images-one-as-base-with-tools-others-for-different-applications)\n- [CLI reference](#command-line-reference)\n- [.docker-make.yml reference](docs/yaml-configuration-reference.md)\n\n## installation\n### install via pip\n`docker-make` is a Python project, so you can install it via pip:\n\n```bash\npip install docker-make\n```\n\n### install via alias to docker run\nor you can just execute it with a `docker run` command, and for convenience, you can set an alias:\n\n#### unixy\n\n```bash\nalias docker-make=\"docker run --rm -w /usr/src/app \\\n                                   -v ~/.docker:/root/.docker \\\n                                   -v /var/run/docker.sock:/var/run/docker.sock \\\n                                   -v \"${PWD}:/usr/src/app\" jizhilong/docker-make docker-make\"\n```\n\n#### windows\n\n```ps\nfunction docker-make {\n  docker run --rm -w /build `\n    -v \"${HOME}/.docker:/root/.docker\" `\n    -v /var/run/docker.sock:/var/run/docker.sock `\n    -v \"${PWD}:/build\" `\n    jizhilong/docker-make docker-make\n}\n```\n\n## quickstart\n`docker-make` is a user is itself, so you can build a image for it with the following command:\n\n```bash\ngit clone https://github.com/CtripCloud/docker-make.git\ncd docker-make\ndocker-make --no-push\n``` \n\nif all goes well, the console output would look like:\n\n```\nINFO 2016-06-19 01:21:49,513 docker-make(277) docker-make: building\nINFO 2016-06-19 01:21:49,657 docker-make(277) docker-make: attaching labels\nINFO 2016-06-19 01:21:49,748 docker-make(277) docker-make: label added: com.dockermake.git.commitid=\"3d97f0fc382e1f90f77584bbc8193509b835fce0\"\nINFO 2016-06-19 01:21:49,748 docker-make(277) docker-make: build succeed: c4391b6110f6\nINFO 2016-06-19 01:21:49,756 docker-make(277) docker-make: tag added: jizhilong/docker-make:3d97f0fc382e1f90f77584bbc8193509b835fce0\nINFO 2016-06-19 01:21:49,760 docker-make(277) docker-make: tag added: jizhilong/docker-make:latest\n```\n\n## how it works\ndocker-make read and parse `.docker-make.yml`(configurable via command line) in the root of a git repo,\nin which you specify images to build, each build's Dockerfile, context, repo to push, rules for tagging, dependencies, etc.\n\nWith information parsed from `.docker-make.yml`, `docker-make` will build, tag, push images in a appropriate order with\nregarding to dependency relations.\n\n## typical use cases\n### single image-tag,push on condition\nthis is the most common use case, and `docker-compose` belongs to such case:\n\n```yaml\nbuilds:\n  docker-make:\n    context: /\n    dockerfile: Dockerfile\n    pushes:\n      - 'always=jizhilong/docker-make:{fcommitid}'\n      - 'on_tag=jizhilong/docker-make:{git_tag}'\n      - 'on_branch:master=jizhilong/docker-make:latest'\n    labels:\n      - 'com.dockermake.git.commitid={fcommitid}'\n    dockerignore:\n      - .git\n```\n\n### two images-one for compile, one for deployment\n\n```yaml\nbuilds:\n  dwait:\n    context: /\n    dockerfile: Dockerfile.dwait\n    extract:\n      - /usr/src/dwait/bin/.:./dwait.bin.tar\n\n  dresponse:\n    context: /\n    dockerfile: Dockerfile\n    pushes:\n      - 'on_branch:master=hub.privateregistry.com/dresponse:latest'\n      - 'on_branch:master=hub.privateregistry.com/dresponse:{fcommitid}'\n    depends_on:\n      - dwait\n```\n\nIn this case, golang codes of the project are compiled in `dwait`, the compiled binary is extracted out by `docker-make`\nand installed to `dresponse` with a `ADD` instruction in `dresponse`'s Dockerfile.Finally, `dresponse` is pushed to a private\nregistry with two tags, git sha-1 commit id and 'latest'.\nWith `docker-make`, you can do all of these steps properly via a single command；\n\n```\n$ docker-make\nINFO 2016-06-19 21:06:09,088 docker-make(278) dwait: building\nINFO 2016-06-19 21:06:09,440 docker-make(278) dwait: build succeed: ed169e889ecc\nINFO 2016-06-19 21:06:09,440 docker-make(278) dwait: extracting archives\nINFO 2016-06-19 21:06:09,599 docker-make(278) dwait: extracting archives succeed\nINFO 2016-06-19 21:06:09,600 docker-make(278) dresponse: building\nINFO 2016-06-19 21:06:10,305 docker-make(278) dresponse: build succeed: 671062910765\nINFO 2016-06-19 21:06:10,318 docker-make(278) dresponse: tag added: hub.privateregistry.com/dresponseagent:latest\nINFO 2016-06-19 21:06:10,325 docker-make(278) dresponse: tag added: hub.privateregistry.com/dresponseagent:a06fbc3a8af2f0fd12e89f539e481fe7d425c7c3\nINFO 2016-06-19 21:06:10,325 docker-make(278) dresponse: pushing to hub.privateregistry.com/dresponseagent:latest\nINFO 2016-06-19 21:06:17,576 docker-make(278) dresponse: pushed to hub.privateregistry.com/dresponseagent:latest\nINFO 2016-06-19 21:06:17,576 docker-make(278) dresponse: pushing to hub.privateregistry.com/dresponseagent:a06fbc3a8af2f0fd12e89f539e481fe7d425c7c3\nINFO 2016-06-19 21:06:18,505 docker-make(278) dresponse: pushed to hub.privateregistry.com/dresponseagent:a06fbc3a8af2f0fd12e89f539e481fe7d425c7c3\n```\n\nwhile the equivalent raw `docker` commands could be quite long, and require a careful atttension to the order of commands:\n\n```bash\n$ docker build -t dmake -f Dockerfile.dwait\n$ tmp_container=`docker create dmake`\n$ docker cp $tmp_container:/usr/src/dwait/bin dwait.bin.tar\n$ docker build -t dresponse Dockerfile\n$ docker tag dresponsehu b.privateregistry.com/dresponse:latest\n$ docker tag dresponsehu b.privateregistry.com/dresponse:${git rev-parse HEAD}\n```\n\n### two images-one for deploy, one for unit tests\n\n```yaml\nbuilds:\n  novadocker:\n    context: /\n    dockerfile: dockerfiles/Dockerfile\n    pushes:\n      - 'on_tag=hub.privateregistry.com/novadocker:{git_tag}'\n    dockerignore:\n      - .dmake.yml\n      - .gitignore\n      - tools\n      - contrib\n      - doc\n    labels:\n      - \"com.dockermake.git.commitid={fcommitid}\"\n\n  novadocker-test:\n    context: dockerfiles/\n    dockerfile: Dockerfile.test\n    rewrite_from: novadocker\n    depends_on:\n      - novadocker\n```\n\nIn this case, `novadocker` is built for deployment, `novadocker-teset` inherits from it via a 'FROM' instruction.\nThe primary content of 'Dockerfile.test' includes installing testing dependencies and running the unit tests, if\nthe tests pass, `docker build` will succeed, otherwise it will fail.Finally, `novadocker` will be pushed to a private\nregistry, if the image is built on a git tag.\n\nThe equivalent job could be expressed with some bash scripts.\n\n```bash\nset -e\nfcommitid=`git rev-parse HEAD`\ndocker build -t novadocker -f dockerfiles/Dockerfile --label com.dockermake.git.commitid=$fcommitid .\ndocker build -t novadocker-test -f dockerfiles/Dockerfile.test .\n\nif git show-ref --tags|grep $fcommitid; then\n   tagname=`git describe` \n   docker tag novadocker hub.privateregistry.com/novadocker:$tagname\n   docker push novadocker hub.privateregistry.com/novadocker:$tagname\nfi\n```\n\n### several images-one as base with tools, others for different applications\n\n```yaml\nbuilds:\n  base:\n    context: base\n    dockerfile: Dockerfile\n\n  java:\n    context: java\n    dockerfile: Dockerfile\n    rewrite_from: base\n    depends_on:\n      - base\n\n  php:\n    context: php\n    dockerfile: Dockerfile\n    rewrite_from: base\n    depends_on:\n      - base\n\n  java-app1:\n    context: app1\n    dockerfile: Dockerfile\n    rewrite_from: java\n    depends_on:\n      - java\n\n  php-app1:\n    context: app2\n    dockerfile: Dockerfile\n    rewrite_from: php \n    depends_on:\n      - php\n```\n\nIn such case, libraries like libc and monitoring tools are installed in base's Dockerfile.\nA java runtime environment and a php runtime environment are built by inheriting from the base image.\nWith java and php as the base images, a java app and a php app are built.\n\n## command line reference\n\n```bash\n$ docker-make --help\nusage: docker-make [-h] [-f DMAKEFILE] [-d] [-rm] [--dry-run] [--no-push]\n                   [builds [builds ...]]\n\nbuild docker images in a simpler way.\n\npositional arguments:\n  builds                builds to execute.\n\noptional arguments:\n  -h, --help            show this help message and exit\n  -f DMAKEFILE, --file DMAKEFILE\n                        path to docker-make configuration file.\n  -d, --detailed        print out detailed logs\n  -rm, --remove         remove intermediate containers\n  --dry-run             print docker commands only\n  --no-push             build only, dont push\n```\n","funding_links":[],"categories":["Docker Images","Dev Tools"],"sub_categories":["Builder"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FCtripCloud%2Fdocker-make","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FCtripCloud%2Fdocker-make","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FCtripCloud%2Fdocker-make/lists"}