Earthly 容器镜像构建工具 —— 筑梦之路

Makefile + Dockerfile = Earthfile

在使用 Earthly 进行构建镜像时目前强依赖于 buildkit,Earthly 通过 buildkit 支持了一些 Dockerfile  的扩展语法,同时将 Dockerfile 与 Makefile 整合,使得多平台构建和代码化 Dockerfile 变得更加简单;使用  Earthly 可以更加方便的完成 Dockerfile 的代码复用以及更加友好的 CI 自动集成。

# 安装

sudo /bin/sh -c 'wget https://github.com/earthly/earthly/releases/latest/download/earthly-linux-amd64 -O /usr/local/bin/earthly && chmod +x /usr/local/bin/earthly && /usr/local/bin/earthly bootstrap --with-autocomplete'

安装完成后 Earthly 将会启动一个 buildkitd 容器: earthly-buildkitd

# 示例

cat  main.go

package main

import "fmt"

func main() {
    fmt.Println("hello world")
}

cat  Earthlyfile

FROM golang:1.17-alpine
WORKDIR /go-example

build:
    COPY main.go .
    RUN go build -o build/go-example main.go
    SAVE ARTIFACT build/go-example /go-example AS LOCAL build/go-example

docker:
    COPY +build/go-example .
    ENTRYPOINT ["/go-example/go-example"]
    SAVE IMAGE go-example:latest

# 目录结构
~/t/earthlytest ❯❯❯ tree
.
├── Earthfile
└── main.go

0 directories, 2 files

# 通过 earthly 进行构建
~/t/earthlytest ❯❯❯ earthly +docker

后续再总结 

 更强大的容器镜像构建工具 Earthly

GitHub - earthly/earthly: The effortless CI/CD framework that runs anywhere

Get Earthly - Better Builds 

猜你喜欢

转载自blog.csdn.net/qq_34777982/article/details/125388482
今日推荐