2018-12-20 09:22:05 +03:00
SHA := $( shell gitmeta git sha)
TAG := $( shell gitmeta image tag)
BUILT := $( shell gitmeta built)
2019-01-19 12:58:26 +03:00
PUSH := $( shell gitmeta pushable)
2018-12-20 09:22:05 +03:00
2019-02-15 07:32:00 +03:00
VPATH = $( PATH)
2019-01-24 02:48:02 +03:00
KERNEL_IMAGE ?= autonomy/kernel:65ec2e6
TOOLCHAIN_IMAGE ?= autonomy/toolchain:397b293
2019-01-19 12:58:26 +03:00
GOLANG_VERSION ?= 1.11.4
2019-02-15 07:32:00 +03:00
BUILDKIT_VERSION ?= v0.3.3
BUILDKIT_IMAGE ?= moby/buildkit:$( BUILDKIT_VERSION)
BUILDKIT_HOST ?= tcp://0.0.0.0:1234
BUILDKIT_CONTAINER_NAME ?= talos-buildkit
2019-02-15 18:57:27 +03:00
BUILDKIT_CONTAINER_STOPPED := $( shell docker ps --filter name = $( BUILDKIT_CONTAINER_NAME) --filter status = exited --format= '{{.Names}}' 2>/dev/null)
BUILDKIT_CONTAINER_RUNNING := $( shell docker ps --filter name = $( BUILDKIT_CONTAINER_NAME) --filter status = running --format= '{{.Names}}' 2>/dev/null)
2019-02-15 07:32:00 +03:00
UNAME_S := $( shell uname -s)
i f e q ( $( UNAME_S ) , L i n u x )
BUILDCTL_ARCHIVE := https://github.com/moby/buildkit/releases/download/$( BUILDKIT_VERSION) /buildkit-$( BUILDKIT_VERSION) .linux-amd64.tar.gz
e n d i f
i f e q ( $( UNAME_S ) , D a r w i n )
BUILDCTL_ARCHIVE := https://github.com/moby/buildkit/releases/download/$( BUILDKIT_VERSION) /buildkit-$( BUILDKIT_VERSION) .darwin-amd64.tar.gz
e n d i f
BINDIR ?= /usr/local/bin
2018-12-20 09:22:05 +03:00
2019-01-24 02:48:02 +03:00
COMMON_ARGS := --progress= plain
COMMON_ARGS += --frontend= dockerfile.v0
2019-01-19 12:58:26 +03:00
COMMON_ARGS += --local context = .
COMMON_ARGS += --local dockerfile = .
2019-01-24 02:48:02 +03:00
COMMON_ARGS += --frontend-opt build-arg:KERNEL_IMAGE= $( KERNEL_IMAGE)
COMMON_ARGS += --frontend-opt build-arg:TOOLCHAIN_IMAGE= $( TOOLCHAIN_IMAGE)
2019-01-19 12:58:26 +03:00
COMMON_ARGS += --frontend-opt build-arg:GOLANG_VERSION= $( GOLANG_VERSION)
COMMON_ARGS += --frontend-opt build-arg:SHA= $( SHA)
COMMON_ARGS += --frontend-opt build-arg:TAG= $( TAG)
2018-12-20 09:22:05 +03:00
2019-02-15 18:57:27 +03:00
all : ci kernel initramfs rootfs osctl -linux -amd 64 osctl -darwin -amd 64 test lint docs installer
2019-02-15 07:32:00 +03:00
.PHONY : builddeps
builddeps : gitmeta buildctl
gitmeta :
GO111MODULE = off go get github.com/autonomy/gitmeta
buildctl :
@wget -qO - $( BUILDCTL_ARCHIVE) | \
sudo tar -zxf - -C $( BINDIR) --strip-components 1 bin/buildctl
.PHONY : buildkitd
buildkitd :
ifeq (tcp : //0.0.0.0:1234, $( findstring tcp ://0.0.0.0:1234,$ ( BUILDKIT_HOST ) ) )
i f e q ( $( BUILDKIT_CONTAINER_STOPPED ) , $( BUILDKIT_CONTAINER_NAME ) )
@echo "Removing exited talos-buildkit container"
@docker rm $( BUILDKIT_CONTAINER_NAME)
e n d i f
i f n e q ( $( BUILDKIT_CONTAINER_RUNNING ) , $( BUILDKIT_CONTAINER_NAME ) )
@echo "Starting talos-buildkit container"
@docker run \
--name $( BUILDKIT_CONTAINER_NAME) \
-d \
--privileged \
-p 1234:1234 \
$( BUILDKIT_IMAGE) \
--addr $( BUILDKIT_HOST)
2019-02-15 18:57:27 +03:00
@echo "Wait for buildkitd to become available"
@sleep 5
2019-02-15 07:32:00 +03:00
e n d i f
e n d i f
.PHONY : ci
ci : builddeps buildkitd
2018-12-20 09:22:05 +03:00
2019-01-24 02:48:02 +03:00
base :
2019-02-15 07:32:00 +03:00
@buildctl --addr $( BUILDKIT_HOST) \
build \
2019-01-19 12:58:26 +03:00
--exporter= docker \
--exporter-opt output = build/$@ .tar \
--exporter-opt name = docker.io/autonomy/$@ :$( TAG) \
--frontend-opt target = $@ \
$( COMMON_ARGS)
@docker load < build/$@ .tar
kernel :
2019-02-15 07:32:00 +03:00
@buildctl --addr $( BUILDKIT_HOST) \
build \
2019-01-19 12:58:26 +03:00
--exporter= local \
--exporter-opt output = build \
--frontend-opt target = $@ \
$( COMMON_ARGS)
2019-01-18 06:14:52 +03:00
2019-01-19 12:58:26 +03:00
initramfs :
2019-02-15 07:32:00 +03:00
@buildctl --addr $( BUILDKIT_HOST) \
build \
2019-01-19 12:58:26 +03:00
--exporter= local \
--exporter-opt output = build \
--frontend-opt target = $@ \
$( COMMON_ARGS)
2018-12-20 09:22:05 +03:00
2019-01-19 12:58:26 +03:00
rootfs : hyperkube etcd coredns pause osd trustd proxyd blockd
2019-02-15 07:32:00 +03:00
@buildctl --addr $( BUILDKIT_HOST) \
build \
2019-01-19 12:58:26 +03:00
--exporter= local \
--exporter-opt output = build \
--frontend-opt target = $@ \
$( COMMON_ARGS)
2018-12-20 09:22:05 +03:00
2019-01-19 12:58:26 +03:00
installer :
2019-02-15 07:32:00 +03:00
@buildctl --addr $( BUILDKIT_HOST) \
build \
2019-01-19 12:58:26 +03:00
--exporter= docker \
--exporter-opt output = build/$@ .tar \
--exporter-opt name = docker.io/autonomy/$@ :$( TAG) \
--exporter-opt push = $( PUSH) \
--frontend-opt target = $@ \
$( COMMON_ARGS)
@docker load < build/$@ .tar
2019-01-24 02:48:02 +03:00
@docker run --rm -v /dev:/dev -v $( PWD) /build:/out --privileged autonomy/$@ :$( TAG) image -l
2018-12-20 09:22:05 +03:00
2019-01-19 12:58:26 +03:00
.PHONY : docs
docs :
@rm -rf ./docs
2019-02-15 07:32:00 +03:00
@buildctl --addr $( BUILDKIT_HOST) \
build \
2019-01-19 12:58:26 +03:00
--exporter= local \
--exporter-opt output = . \
--frontend-opt target = $@ \
$( COMMON_ARGS)
2018-12-20 09:22:05 +03:00
test :
2019-02-15 07:32:00 +03:00
@buildctl --addr $( BUILDKIT_HOST) \
build \
2019-01-19 12:58:26 +03:00
--frontend-opt target = $@ \
$( COMMON_ARGS)
2018-12-20 09:22:05 +03:00
2019-01-18 17:26:12 +03:00
lint :
2019-02-15 07:32:00 +03:00
@buildctl --addr $( BUILDKIT_HOST) \
build \
2019-01-19 12:58:26 +03:00
--frontend-opt target = $@ \
$( COMMON_ARGS)
osctl-linux-amd64 :
2019-02-15 07:32:00 +03:00
@buildctl --addr $( BUILDKIT_HOST) \
build \
2019-01-19 12:58:26 +03:00
--exporter= local \
--exporter-opt output = build \
--frontend-opt target = $@ \
$( COMMON_ARGS)
osctl-darwin-amd64 :
2019-02-15 07:32:00 +03:00
@buildctl --addr $( BUILDKIT_HOST) \
build \
2019-01-19 12:58:26 +03:00
--exporter= local \
--exporter-opt output = build \
--frontend-opt target = $@ \
$( COMMON_ARGS)
udevd :
2019-02-15 07:32:00 +03:00
@buildctl --addr $( BUILDKIT_HOST) \
build \
2019-01-19 12:58:26 +03:00
--frontend-opt target = $@ \
$( COMMON_ARGS)
osd :
2019-02-15 07:32:00 +03:00
@buildctl --addr $( BUILDKIT_HOST) \
build \
2019-01-19 12:58:26 +03:00
--exporter= docker \
--exporter-opt output = images/$@ .tar \
--exporter-opt name = docker.io/autonomy/$@ :$( TAG) \
--frontend-opt target = $@ \
$( COMMON_ARGS)
trustd :
2019-02-15 07:32:00 +03:00
@buildctl --addr $( BUILDKIT_HOST) \
build \
2019-01-19 12:58:26 +03:00
--exporter= docker \
--exporter-opt output = images/$@ .tar \
--exporter-opt name = docker.io/autonomy/$@ :$( TAG) \
--frontend-opt target = $@ \
$( COMMON_ARGS)
proxyd :
2019-02-15 07:32:00 +03:00
@buildctl --addr $( BUILDKIT_HOST) \
build \
2019-01-19 12:58:26 +03:00
--exporter= docker \
--exporter-opt output = images/$@ .tar \
--exporter-opt name = docker.io/autonomy/$@ :$( TAG) \
--frontend-opt target = $@ \
$( COMMON_ARGS)
blockd :
2019-02-15 07:32:00 +03:00
@buildctl --addr $( BUILDKIT_HOST) \
build \
2019-01-19 12:58:26 +03:00
--exporter= docker \
--exporter-opt output = images/$@ .tar \
--exporter-opt name = docker.io/autonomy/$@ :$( TAG) \
--frontend-opt target = $@ \
$( COMMON_ARGS)
2019-01-18 17:26:12 +03:00
2019-01-16 05:46:41 +03:00
hyperkube :
2019-02-06 07:11:39 +03:00
@docker pull k8s.gcr.io/$@ :v1.13.3
@docker save k8s.gcr.io/$@ :v1.13.3 -o ./images/$@ .tar
2019-01-16 05:46:41 +03:00
etcd :
@docker pull k8s.gcr.io/$@ :3.2.24
@docker save k8s.gcr.io/$@ :3.2.24 -o ./images/$@ .tar
coredns :
@docker pull k8s.gcr.io/$@ :1.2.6
@docker save k8s.gcr.io/$@ :1.2.6 -o ./images/$@ .tar
pause :
@docker pull k8s.gcr.io/$@ :3.1
@docker save k8s.gcr.io/$@ :3.1 -o ./images/$@ .tar
2018-12-20 09:22:05 +03:00
clean :
2019-01-19 12:58:26 +03:00
-go clean -modcache
-rm -rf build vendor