2019-02-23 20:31:49 +03:00
SHA = $( shell gitmeta git sha)
TAG = $( shell gitmeta image tag)
BUILT = $( shell gitmeta built)
PUSH = $( shell gitmeta pushable)
2018-12-20 09:22:05 +03:00
2019-02-15 07:32:00 +03:00
VPATH = $( PATH)
2019-02-21 16:34:52 +03:00
KERNEL_IMAGE ?= autonomy/kernel:e8147aa
2019-03-22 15:46:33 +03:00
TOOLCHAIN_IMAGE ?= autonomy/toolchain:0341dfd
2019-03-11 15:42:22 +03:00
GOLANG_VERSION ?= 1.12
2019-02-20 07:58:06 +03:00
DOCKER_ARGS ?=
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
2019-03-05 06:52:52 +03:00
CONFORM_VERSION ?= 1473b44
2018-12-20 09:22:05 +03:00
2019-02-23 20:31:49 +03:00
COMMON_ARGS = --progress= plain
2019-01-24 02:48:02 +03:00
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-24 00:18:52 +03:00
all : ci kernel initramfs rootfs osctl -linux -amd 64 osctl -darwin -amd 64 osinstall -linux -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
2019-02-19 08:35:47 +03:00
enforce :
@docker run --rm -v $( PWD) :/src -w /src autonomy/conform:$( CONFORM_VERSION)
2019-02-15 07:32:00 +03:00
.PHONY : ci
ci : builddeps buildkitd
2018-12-20 09:22:05 +03:00
2019-02-28 05:57:35 +03:00
base : buildkitd
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
2019-02-28 05:57:35 +03:00
kernel : buildkitd
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-02-28 05:57:35 +03:00
initramfs : buildkitd
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-03-24 01:58:13 +03:00
rootfs : buildkitd hyperkube etcd coredns pause osd trustd proxyd blockd ntpd
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-03-10 07:53:32 +03:00
container-os : buildkitd
2019-03-09 22:12:35 +03:00
@buildctl --addr $( BUILDKIT_HOST) \
build \
--exporter= docker \
--exporter-opt output = build/$@ .tar \
--exporter-opt name = docker.io/autonomy/talos-os:$( TAG) \
--exporter-opt push = $( PUSH) \
--frontend-opt target = $@ \
$( COMMON_ARGS)
@docker load < build/$@ .tar
2019-02-28 05:57:35 +03:00
installer : buildkitd
@mkdir -p build
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 \
2019-02-20 07:58:06 +03:00
--exporter-opt name = docker.io/autonomy/talos:$( TAG) \
2019-01-19 12:58:26 +03:00
--exporter-opt push = $( PUSH) \
--frontend-opt target = $@ \
$( COMMON_ARGS)
@docker load < build/$@ .tar
2019-02-19 19:41:41 +03:00
image-gcloud : installer
2019-02-20 07:58:06 +03:00
@docker run --rm -v /dev:/dev -v $( PWD) /build/gcloud:/out --privileged $( DOCKER_ARGS) autonomy/talos:$( TAG) image -l \
2019-02-19 19:41:41 +03:00
-f -p googlecloud -u none -e 'random.trust_cpu=on'
@mv $( PWD) /build/gcloud/image.raw $( PWD) /build/gcloud/disk.raw
@tar -C $( PWD) /build/gcloud -Sczf $( PWD) /build/gcloud/talos.tar.gz disk.raw
image-vanilla : installer
2019-02-20 07:58:06 +03:00
@docker run --rm -v /dev:/dev -v $( PWD) /build:/out --privileged $( DOCKER_ARGS) autonomy/talos:$( TAG) image -l
2018-12-20 09:22:05 +03:00
2019-01-19 12:58:26 +03:00
.PHONY : docs
2019-02-28 05:57:35 +03:00
docs : buildkitd
2019-01-19 12:58:26 +03:00
@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
2019-02-28 05:57:35 +03:00
test : buildkitd
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-02-28 05:57:35 +03:00
lint : buildkitd
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)
2019-02-28 05:57:35 +03:00
osctl-linux-amd64 : buildkitd
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-02-28 05:57:35 +03:00
osctl-darwin-amd64 : buildkitd
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-02-28 05:57:35 +03:00
osinstall-linux-amd64 : buildkitd
2019-02-24 00:18:52 +03:00
@buildctl --addr $( BUILDKIT_HOST) \
build \
--exporter= local \
--exporter-opt output = build \
--frontend-opt target = $@ \
$( COMMON_ARGS)
2019-02-28 05:57:35 +03:00
udevd : buildkitd
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)
2019-02-28 05:57:35 +03:00
osd : buildkitd
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-02-28 05:57:35 +03:00
trustd : buildkitd
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-02-28 05:57:35 +03:00
proxyd : buildkitd
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-02-28 05:57:35 +03:00
blockd : buildkitd
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-03-24 01:58:13 +03:00
ntpd : buildkitd
@buildctl --addr $( BUILDKIT_HOST) \
build \
--exporter= docker \
--exporter-opt output = images/$@ .tar \
--exporter-opt name = docker.io/autonomy/$@ :$( TAG) \
--frontend-opt target = $@ \
$( COMMON_ARGS)
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