ドッカーを構築するためのMakefileを使用しました
ドッキングウィンドウのコマンドを学習の開始時に、それがコマンドを覚えますので単語は、ノック言葉のようなものです。その後に精通している、あなたはいくつかの操作をしたいたびにする必要があります
前のコマンドの入力を繰り返します。historyコマンドの加速度が限られているだけで、プログラムへの切り替え、同一類似のではなく、コマンドを再入力するとき。
だから私は、書かれたコマンドシェルを使用して、それを行うには、シェルスクリプトを呼び出すために、と思います。確かにそうすることを始めて。たとえばhttps://github.com/Ryan-Miao/docker-yapi。
1日までは、Makefileのストレージ事業、及び瞬時に最高の気分を使用して誰かを見つけることができます。
ここでは、単純なレコードの簡単な使用のMakefileです。
Makefileは何ですか
Makefileのルールの設定ファイルは、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 makeがおおよそメンテナンスや組織のプログラムを言うことです。例えば、そのようなソースとして、私たちのC言語コンパイラ、およびそのようなnginxの時間のようないくつかのソフトウェアをインストールします。どのような地獄GNUだから?
GNU(GNUのないUnixの)Unixライクなシステムであり、目標は完全にフリーなオペレーティングシステムを作成することです。Linuxが表示される前に、GNUはカーネルに加えて、ソフトウェアのほとんどを完了しました。GNUと組み合わせるのLinuxの登場、後になりますGNU/Linux
。
厳密に言えば、それは、LinuxカーネルのLinuxのLinuxディストリビューションと呼ばれ、他のLinuxソフトウェアを表します。名前が変更されているものの、商業出版社によるは、Linuxの呼び出しを主張するGNU/Linux
が、我々はまだ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
Makefileの基本的な文法
ここでは、認知コストを削減するため、使用された知識のリストだけで、詳細な付録のリファレンスを参照してください。
カレントディレクトリにあるMakefileというファイルを作成します。
変数を宣言します
そのようなステートメント名などの単純な変数の割り当て、
name=ryan
ステートメントルールルール
Makefileファイルには、ルール(規則)のセットで構成されます。次のように各ルールの形です。
<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