도커를 구축하기 위해 Makefile을 사용하여

도커를 구축하기 위해 Makefile을 사용하여

고정 표시기 명령을 학습의 시작 부분에서, 그것은 명령을 기억하기 때문에 단어, 노크 단어 같다. 나중에 잘 알고, 당신은 몇 가지 작업을 수행 할 때마다해야 할 것이다
이전 명령 입력을 반복합니다. 프로그램으로 전환 한 경우에만 기록 명령 가속도 명령 유사하지만 동일하지 않은 재 입력은 제한된다.

그래서 내가 작성 명령 쉘을 사용하고 그것을 할 쉘 스크립트를 호출하는 생각. 실제로 그렇게하기 시작했다. 예를 들어 https://github.com/Ryan-Miao/docker-yapi.
어느 날, 메이크 스토리지 운영 및 즉시 좋은 느낌을 사용하는 사람을 찾을 수 있습니다.

다음은 간단한 기록 간단한 사용 메이크입니다.

메이크 무엇입니까

메이크 규칙 구성 파일은 make 명령입니다. 명령은 무엇 만들어?

의 만들 수있는 위치를 살펴 보자

~ > whereis make
make: /usr/bin/make /usr/share/man/man1/make.1.gz

빈에서 실행 파일을 만들어 볼 수있다. 사용자 설명서를 살펴 보자

MAKE(1)                                                          User Commands                                                         MAKE(1)

NAME
       make - GNU make utility to maintain groups of programs

SYNOPSIS
       make [OPTION]... [TARGET]...

DESCRIPTION
       The  make  utility will determine automatically which pieces of a large program need to be recompiled, and issue the commands to recom‐
       pile them.  The manual describes the GNU implementation of make, which was written by Richard Stallman and Roland McGrath, and is  cur‐
       rently  maintained  by Paul Smith.  Our examples show C programs, since they are very common, but you can use make with any programming
       language whose compiler can be run with a shell command.  In fact, make is not limited to programs.  You can use  it  to  describe  any
       task where some files must be updated automatically from others whenever the others change.

       To prepare to use make, you must write a file called the makefile that describes the relationships among files in your program, and the
       states the commands for updating each file.  In a program, typically the executable file is updated from object  files,  which  are  in
       turn made by compiling source files.

       Once a suitable makefile exists, each time you change some source files, this simple shell command:

              make

       suffices  to  perform  all necessary recompilations.  The make program uses the makefile description and the last-modification times of
       the files to decide which of the files need to be updated.  For each of those files, it issues the commands recorded in the makefile.

       make executes commands in the makefile to update one or more target names, where name is typically a  program.   If  no  -f  option  is
       present, make will look for the makefiles GNUmakefile, makefile, and Makefile, in that order.

       Normally  you  should  call  your makefile either makefile or Makefile.  (We recommend Makefile because it appears prominently near the
       beginning of a directory listing, right near other important files such as README.)  The first name checked, GNUmakefile, is not recom‐
       mended for most makefiles.  You should use this name if you have a makefile that is specific to GNU make, and will not be understood by
       other versions of make.  If makefile is '-', the standard input is read.

       make updates a target if it depends on prerequisite files that have been modified since the target was last modified, or if the  target
       does not exist.

GNU 메이크업은 거의 유지 보수 및 조직 프로그램을 말을하는 것입니다. 예를 들어, 우리의 C 언어 등의 소스로 컴파일러, 다음 등의 nginx 시간으로, 일부 소프트웨어를 설치합니다. 그래서 도대체 GNU?

GNU (GNU의 않음 유닉스)는 유닉스 계열 시스템, 목표는 완전 무료 운영 체제를 만드는 것입니다. 리눅스가 나타나기 전에, GNU 커널에 추가 소프트웨어의 대부분을 완료했습니다. 는 GNU와 함께 리눅스의 출현, 후가 될 GNU/Linux.
엄밀히 말하면, 그것은 리눅스 커널 리눅스의 리눅스 배포판이라고, 다른 리눅스 소프트웨어를 나타냅니다. 이름이 변경되었습니다 있지만 그러나 상업 출판사로 인해 리눅스를 호출 주장 GNU/Linux하지만, 우리는 여전히 리눅스했다.

## 比如我的本机Ubuntu
~ ❯ uname
Linux
~ ❯ uname -a
Linux ryan-computer 4.18.0-20-generic #21~18.04.1-Ubuntu SMP Wed May 8 08:43:37 UTC 2019 x86_64 x86_64 x86_64 GNU/Linux

## 大部分基于Debian的docker镜像
airflow@88e36c088b81:~$ cat /etc/issue
Debian GNU/Linux 9 \n \l

## RedHat
[root@data-docker001 docker-airflow]# cat /etc/redhat-release 
CentOS Linux release 7.4.1708 (Core) 
[root@data-docker001 docker-airflow]# uname -a                
Linux data-docker001 3.10.0-693.2.2.el7.x86_64 #1 SMP Tue Sep 12 22:26:13 UTC 2017 x86_64 x86_64 x86_64 GNU/Linux

기본 사용법은 확인하는 것입니다

make target

메이크 기초 문법

인지 비용, 사용 된 지식의 목록을 줄이기 위해 여기 자세한 부록 참조를 참조하십시오.

현재 디렉토리에 메이크라는 파일을 만듭니다.

변수 선언

같은 명령문 이름이 같은 간단한 변수 할당,

name=ryan

문 규칙 규칙

메이크 파일 규칙 (규칙)의 세트로 구성되어 있습니다. 다음과 같이 각각의 룰의 형태이다.

<target> : <prerequisites> 
[tab]  <commands>
  • 대상 목표
  • 전제 조건 전제 조건
  • 탭 명령 탭으로 구분해야합니다
  • 쉘 명령의 한 줄이있을 수 있습니다

대상과 동일한 파일 이름을 방지

우리가 현재 디렉토리와 같은 일을 설정 대상의 파일 이름, 대상이 무시됩니다 때, 그래서, 일반적으로, 우리는 가짜 목적물을 사용하는 대상입니다.

.PHONY: build start push

그는 시작은 현재 디렉토리에있는 파일을 확인하지 않고,이 3 개의 대상을 밀어 구축에 직접 명령을 실행 나타냅니다.

고정 표시기와 빌드 지침

나는 다음과 같은 Makefile을 사용

NAME = ryan/airflow
VERSION = 1.10.4

.PHONY: build start push

build:  build-version

build-version:
        docker build -t ${NAME}:${VERSION}  .

tag-latest:
        docker tag ${NAME}:${VERSION} ${NAME}:latest

start:
        docker run -it --rm ${NAME}:${VERSION} /bin/bash

push:   build-version tag-latest
        docker push ${NAME}:${VERSION}; docker push ${NAME}:latest

이미지의 버전을 빌드하려면

make build

완성 된 건물, 거울을 실행 내용을 보면 정확

make start

마지막으로 고정 표시기웨어 하우스로 밀어

make push

참고

추천

출처www.cnblogs.com/woshimrf/p/make-docker.html