docker-makefile

Makefile for building docker repository releases
授权协议 Apache-2.0 License
开发语言 SHELL
所属分类 应用工具、 终端/远程登录
软件类型 开源软件
地区 不详
投 递 者 东方谦
操作系统 跨平台
开源组织
适用人群 未知
 软件概览

Generic Docker Makefile

When working with the Docker hub, two small things bothered me:

  1. Waiting for your build to start
  2. No easy control over the tags for the images.

To resolve these to issues, I created a generic Makefile that allows you to build and release docker images based upon git tags, whenever you want.

Makefile targets

The Makefile has the following targets:

make patch-release	increments the patch release level, build and push to registry
make minor-release	increments the minor release level, build and push to registry
make major-release	increments the major release level, build and push to registry
make release		build the current release and push the image to the registry
make build		builds a new version of your Docker image and tags it
make snapshot		build from the current (dirty) workspace and pushes the image to the registry 
make check-status	will check whether there are outstanding changes
make check-release	will check whether the current directory matches the tagged release in git.
make showver		will show the current release tag based on the directory content.

How to use it.

copy the Makefile and .make-release-support into your Docker git project:

wget -O Makefile.mk https://raw.githubusercontent.com/mvanholsteijn/docker-makefile/master/Makefile
wget https://raw.githubusercontent.com/mvanholsteijn/docker-makefile/master/.make-release-support

Change registry, user or image name

By default, the registry is set to docker.io and the user to the current user. To override this, edit the Makefileand set the variables REGISTRY_HOST, USERNAME and NAME.

include Makefile.mk

REGISTRY_HOST=myregistry.io
USERNAME=mvanholsteijn
NAME=awesome-image

Building an image

to build an image, add a Dockerfile to your directory and type make:

make

Release

To make a release and tag it, commit add the changes and type:

make	patch-release

This will bump the patch-release number, build the image and push it to the registry. It will onlyrelease if there are no outstanding changes and the content of the directory equals the tagged content.

Alternatively you can choose 'make minor-release' or 'make major-release' to bump the associated number.

Release number

The release of your docker image is kept in the file .release and uses the following format:

release=<major>.<minor>.<patch>

The name of the git tag is kept in the same file, and by default will have the format:

tag=<directory-name>.<minor>.<patch>

This will allow you to have track and tag multiple images in a single Git repository.

If you want to use a different tag prefix, change it in the .release.

Image name and tag

The name of the image will be created as follows:

	<registry-host>/<username>/<directory name>:<tag>

The tag is has the following format:

format when
<release> the contents of the directory is equal to tagged content in git
<release>-<commit> the contents of the directory is not equal to the tagged content
<release>-<commit>-dirty the contents of the directory has uncommitted changes

Multiple docker images in a single git repository.

If you want to maintain multiple docker images in a single git repository, you can use an alternate setup where the Makefile is located in a silbing directory.

├── multiple-example
│   ├── ...
│   ├── image1
│   │   ├── .release
│   │   ├── Dockerfile
│   │   └── Makefile
│   ├── image2
│   │   ├── .release
│   │   ├── Dockerfile
│   │   └── Makefile
│   └── make
│       ├── .make-release-support
│       ├── Makefile

The Makefile in the image directories will include the generic Makefile. In this Makefile you can alter the names and tailor the build by adding pre and post build targets. Checkout the directory (multiple-example) for an example.

Create the generic make directory

To create the generic make directory, type:

mkdir make
cd make
wget  https://raw.githubusercontent.com/mvanholsteijn/docker-makefile/master/Makefile  
wget  https://raw.githubusercontent.com/mvanholsteijn/docker-makefile/master/.make-release-support

Create docker image directory

For each docker images, you create a sibling directory:

mkdir ../image1
cd ../image1

cat > Makefile <<!
include ../make/Makefile

USERNAME=mvanholsteijn

pre-build:
	@echo do some stuff before the docker build

post-build:
	@echo do some stuff after the docker build
!

Now you can use the make build and release instructions to build these images.

Changing the build context and Dockerfile path and name

Use the DOCKER_BUILD_CONTEXTvariable to set the path to the context. Set DOCKER_FILE_PATH to change the path to the Dockerfile (file name included) you want to use. Using this in conjuction with the pre-build and post-build targets and a .dockerignore file allows you to modify the build context.

DOCKER_BUILD_CONTEXT=../..
DOCKER_FILE_PATH=$(DOCKER_BUILD_CONTEXT)/docker/$(NAME)/some.Dockerfile

pre-build: check-env-vars .dockerignore
	cp .dockerignore $(DOCKER_BUILD_CONTEXT)

post-build:
	rm $(DOCKER_BUILD_CONTEXT)/.dockerignore

pre tag command

If you want add the current release to a source file, you can add the property pre\_tag\_command to the .release file.this command is executed when the .release file is updated and before the tag is placed. In the command @@RELEASE@@ isreplaced with the current release before it is executed. For example:

release=0.1.0
tag=v0.1.0
pre_tag_command=sed -i "" -e 's/^version=.*/version="@@RELEASE@@"/' setup.py

Adding --build-arg

If you want to add any command line options to the docker build command, specify the Makevariable DOCKER_BUILD_ARGS.

The following Makefile, specifies the build argument TAG_VERSION to be set to the current value.

include ../Makefile
DOCKER_BUILD_ARGS=--build-arg TAG_VERSION=$(VERSION)

checkout the example Make- and Dockerfile.

  • 计划使用fabric 2.x 的externalBuilds 构建外部的链码服务,在这个过程中发现了,无法使用对应的二进制包,会出现/bin/sh: ./build: not found 错误,解决办法将build 文件开头的   #!/bin/bash 修改为#!/bin/sh  

  • [解決済み] php:*-alpine のdocker buildで、`make: /bin/sh: Operation not permitted` エラーが発生する PHPDockeralpine はじめに(何が問題か) 以下のようなDockerfileをビルドすると、 FROM php:7.4-cli-alpine RUN set -ex \ && apk --no-cache add

  • ==参考链接:博主:GoRustNeverStop----linux杂谈—https://blog.csdn.net/weiyuefei/article/details/16858025 http://blog.csdn.net/s_gy_zetrov Docker,可以说是一个终端命令行的虚拟机,但更准确的说是一个虚拟环境。比如说你想在PC上无缝使用Linux,虚拟机并不是你唯一的出路,你还有D

  • ①故障现象 场景:基于 Dockerfile 创建一个最基本的 httpd 镜像 报错代码如下: [root@localhost ~]docker build -t httpd:centos . ... ... Step 3/9 : RUN yum -y update ---> [Warning] IPv4 forwarding is disabled. Networking will not

  • include .env export build: docker buildx build --platform linux/amd64 -t ${IMAGE_NAME}:${VERSION}-${ENV} --build-arg APP_NAME=${IMAGE_NAME} . docker tag ${IMAGE_NAME}:${VERSION}-${ENV} ${REGIST

  • 1. dockerfile打包后操作: apt-get update 2. 报错 Couldn’t create temporary file /tmp/apt.conf.R6cSTc for passing config to apt-key 3.原因: 无法将配置文件传递给apt-key apt-key等等实际上并不是直接使用/etc/apt/apt.conf配置文件,而是每次执行操作的时候将

  • 当我加入我当前的公司时,我在他们的git仓库中看到了奇怪的文件。没有任何Python代码使用它。它仅仅是存在于项目的主目录下。我问我的同事,这个文件是用来干嘛的?他们告诉我——它让你的生活更轻松。这就是为什么今天我要写写这个文件 - Makefile。 目录: makefile是什么,以及它的典型用途 具体到Python,你可以把什么放到makefile中 通过在Python项目中使用makefi

  • 结构 DockerFile分为四部分组成:基础镜像信、维护者信息、镜像操作指令和容器启动时执行指令。例如: #第一行必须指令基于的基础镜像 From ubutu #维护者信息 MAINTAINER docker_user docker_user@mail.com #镜像的操作指令 apt/sourcelist.list RUN apt-get update && apt-get insta

  • MYSQL(包要放在mysql)下 在opt下 创建mysql文件夹 mkdir mysql #创建mysql目录 进入mysql的目录中 cd mysql/ #进入mysql的目录中 编写dockerfile文件 vim Dockerfile FROM centos:7.4.1708 ADD mysql-5.6.26.tar.gz /opt RUN curl -o /etc/yum.rep

 相关资料
  • 一、解决的问题 二、与虚拟机的比较 三、优势 四、使用场景 五、镜像与容器 参考资料 一、解决的问题 由于不同的机器有不同的操作系统,以及不同的库和组件,在将一个应用部署到多台机器上需要进行大量的环境配置操作。 Docker 主要解决环境配置问题,它是一种虚拟化技术,对进程进行隔离,被隔离的进程独立于宿主操作系统和其它隔离的进程。使用 Docker 可以不修改应用程序代码,不需要开发人员学习特定环

  • 我检查了垃圾箱,里面没有ping

  • 第一章 Docker介绍1 1.1 docker简介 Docker 是一个开源的应用容器引擎,让开发者可以打包他们的应用以及依赖包到一个可移植的容器中,然后发布到任何流行的\[Linux\]机器上,也可以实现\[虚拟化\]。容器是完全使用\[沙箱\]机制,相互之间不会有任何接口。 1.2 Docker是什么? Docker是一个程序运行、测试、交付的开放平台,Docker被设计为能够使你快速地交

  • 推荐使用 Swoole 官方 Docker:https://github.com/swoole/docker-swoole

  • Docker Commands Commands Notes docker ps -a Show all containers on the system docker ps Show only currently running containers docker run <NAME> Creates & runs a docker container via an image docker i

  • 环境准备 1. 下载镜像及配置文件 链接: https://pan.baidu.com/s/1hw0h1KUlhSirFBId6kh8mw 提取码: 1wng $ ls backend-0.0.8.tar.gz env.list grpc-go-greeting-0.1.tar.gz nginx-lb.conf nginx-perf.conf nginxplus-23-r1.tar.

  • 本部分常用命令1. docker network docker network create docker network ls docker network inspect docker network rm // 将一个已经存在的容器加入到一个 docker 网络 docker network connect docker network disconnect2. 基本命令调试相关

  • Docker 是一个开源的应用容器引擎,让开发者可以打包他们的应用以及依赖包到一个可移植的容器中,然后发布到任何流行的 Linux 机器上,也可以实现虚拟化。 容器是完全使用沙箱机制,相互之间不会有任何接口(类似 iPhone 的 app)。几乎没有性能开销,可以很容易地在机器和数据中心中运行。最重要的是,他们不依赖于任何语言、框架或包装系统。