2019-02-23 20:31:49 +03:00
SHA = $( shell gitmeta git sha)
TAG = $( shell gitmeta image tag)
2018-12-20 09:22:05 +03:00
2019-04-24 17:55:44 +03:00
KERNEL_IMAGE ?= autonomy/kernel:d1a36fb
2019-04-19 05:31:43 +03:00
TOOLCHAIN_IMAGE ?= autonomy/toolchain:255b4fd
ROOTFS_IMAGE ?= autonomy/rootfs-base:255b4fd
INITRAMFS_IMAGE ?= autonomy/initramfs-base:255b4fd
# TODO(andrewrynhard): Move this logic to a shell script.
2019-04-29 19:25:04 +03:00
BUILDKIT_VERSION ?= v0.5.0
2019-04-29 21:51:39 +03:00
KUBECTL_VERSION ?= v1.14.1
2019-02-15 07:32:00 +03:00
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-04-29 21:51:39 +03:00
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
2019-04-29 21:08:01 +03:00
BUILDKIT_CACHE ?= -v $( HOME) /.buildkit:/var/lib/buildkit
2019-02-15 07:32:00 +03:00
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
2019-04-29 21:08:01 +03:00
BUILDKIT_CACHE ?= ""
2019-02-15 07:32:00 +03:00
e n d i f
2019-04-24 04:52:31 +03:00
2019-04-29 21:51:39 +03:00
i f e q ( $( UNAME_S ) , L i n u x )
KUBECTL_ARCHIVE := https://storage.googleapis.com/kubernetes-release/release/$( KUBECTL_VERSION) /bin/linux/amd64/kubectl
e n d i f
i f e q ( $( UNAME_S ) , D a r w i n )
KUBECTL_ARCHIVE := https://storage.googleapis.com/kubernetes-release/release/$( KUBECTL_VERSION) /bin/darwin/amd64/kubectl
e n d i f
2019-04-24 04:52:31 +03:00
BINDIR ?= ./bin
CONFORM_VERSION ?= 57c9dbd
COMMON_ARGS = --progress= plain
COMMON_ARGS += --frontend= dockerfile.v0
COMMON_ARGS += --local context = .
COMMON_ARGS += --local dockerfile = .
COMMON_ARGS += --opt build-arg:KERNEL_IMAGE= $( KERNEL_IMAGE)
COMMON_ARGS += --opt build-arg:TOOLCHAIN_IMAGE= $( TOOLCHAIN_IMAGE)
COMMON_ARGS += --opt build-arg:ROOTFS_IMAGE= $( ROOTFS_IMAGE)
COMMON_ARGS += --opt build-arg:INITRAMFS_IMAGE= $( INITRAMFS_IMAGE)
COMMON_ARGS += --opt build-arg:SHA= $( SHA)
COMMON_ARGS += --opt build-arg:TAG= $( TAG)
DOCKER_ARGS ?=
# to allow tests to run containerd
DOCKER_TEST_ARGS = --security-opt seccomp:unconfined --privileged -v /var/lib/containerd/
2018-12-20 09:22:05 +03:00
2019-04-29 19:25:04 +03:00
all : ci drone
.PHONY : drone
drone : rootfs initramfs kernel installer talos
.PHONY : ci
ci : builddeps buildkitd
2019-02-15 07:32:00 +03:00
.PHONY : builddeps
builddeps : gitmeta buildctl
gitmeta :
2019-04-04 04:29:21 +03:00
GO111MODULE = off go get github.com/talos-systems/gitmeta
2019-02-15 07:32:00 +03:00
2019-04-24 04:52:31 +03:00
buildctl : $( BINDIR ) /buildctl
$(BINDIR)/buildctl :
2019-04-29 19:25:04 +03:00
@mkdir -p $( BINDIR)
2019-04-29 21:51:39 +03:00
@curl -L $( BUILDCTL_ARCHIVE) | tar -zxf - -C $( BINDIR) --strip-components 1 bin/buildctl
kubectl : $( BINDIR ) /kubectl
$(BINDIR)/kubectl :
@mkdir -p $( BINDIR)
@curl -L -o $( BINDIR) /kubectl $( KUBECTL_ARCHIVE)
@chmod +x $( BINDIR) /kubectl
2019-02-15 07:32:00 +03:00
.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 \
2019-04-12 19:52:16 +03:00
-p 1234:1234 \
$( BUILDKIT_CACHE) \
2019-02-15 07:32:00 +03:00
$( 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-04-19 05:31:43 +03:00
.PHONY : binaries
binaries : buildkitd
2019-04-24 04:52:31 +03:00
@$( BINDIR) /buildctl --addr $( BUILDKIT_HOST) \
2019-02-15 07:32:00 +03:00
build \
2019-04-24 04:52:31 +03:00
--output type = local,dest= build \
--opt target = $@ \
2019-01-19 12:58:26 +03:00
$( COMMON_ARGS)
2019-04-24 04:52:31 +03:00
base : buildkitd
@$( BINDIR) /buildctl --addr $( BUILDKIT_HOST) \
build \
--output type = docker,dest= build/$@ .tar,name= docker.io/autonomy/$@ :$( TAG) \
--opt target = $@ \
$( COMMON_ARGS)
2019-04-19 05:31:43 +03:00
.PHONY : kernel
2019-02-28 05:57:35 +03:00
kernel : buildkitd
2019-04-24 04:52:31 +03:00
@$( BINDIR) /buildctl --addr $( BUILDKIT_HOST) \
2019-02-15 07:32:00 +03:00
build \
2019-04-24 04:52:31 +03:00
--output type = local,dest= build \
--opt target = $@ \
2019-01-19 12:58:26 +03:00
$( COMMON_ARGS)
2019-04-16 08:44:59 +03:00
@-rm -rf ./build/modules
2019-01-18 06:14:52 +03:00
2019-04-19 05:31:43 +03:00
.PHONY : initramfs
2019-02-28 05:57:35 +03:00
initramfs : buildkitd
2019-04-24 04:52:31 +03:00
@$( BINDIR) /buildctl --addr $( BUILDKIT_HOST) \
2019-02-15 07:32:00 +03:00
build \
2019-04-24 04:52:31 +03:00
--output type = local,dest= build \
--opt target = $@ \
2019-01-19 12:58:26 +03:00
$( COMMON_ARGS)
2018-12-20 09:22:05 +03:00
2019-04-19 05:31:43 +03:00
.PHONY : rootfs
2019-04-30 18:48:48 +03:00
rootfs : buildkitd binaries osd trustd proxyd ntpd udevd
2019-04-24 04:52:31 +03:00
@$( BINDIR) /buildctl --addr $( BUILDKIT_HOST) \
2019-02-15 07:32:00 +03:00
build \
2019-04-24 04:52:31 +03:00
--output type = local,dest= build \
--opt target = $@ \
2019-01-19 12:58:26 +03:00
$( COMMON_ARGS)
2018-12-20 09:22:05 +03:00
2019-04-19 05:31:43 +03:00
.PHONY : installer
2019-02-28 05:57:35 +03:00
installer : buildkitd
@mkdir -p build
2019-04-24 04:52:31 +03:00
@$( BINDIR) /buildctl --addr $( BUILDKIT_HOST) \
2019-02-15 07:32:00 +03:00
build \
2019-04-24 04:52:31 +03:00
--output type = docker,dest= build/$@ .tar,name= docker.io/autonomy/$@ :$( TAG) \
--opt target = $@ \
2019-01-19 12:58:26 +03:00
$( COMMON_ARGS)
@docker load < build/$@ .tar
2019-02-19 19:41:41 +03:00
2019-04-19 05:31:43 +03:00
.PHONY : proto
2019-03-28 02:33:03 +03:00
proto : buildkitd
2019-04-24 04:52:31 +03:00
$( BINDIR) /buildctl --addr $( BUILDKIT_HOST) \
2019-03-28 02:33:03 +03:00
build \
2019-04-24 04:52:31 +03:00
--output type = local,dest= ./ \
--opt target = $@ \
2019-03-28 02:33:03 +03:00
$( COMMON_ARGS)
2019-04-19 05:31:43 +03:00
.PHONY : talos -gce
2019-04-07 18:25:55 +03:00
talos-gce : installer
2019-04-06 17:24:50 +03:00
@docker run --rm -v /dev:/dev -v $( PWD) /build:/out --privileged $( DOCKER_ARGS) autonomy/installer:$( TAG) disk -l -f -p googlecloud -u none -e 'random.trust_cpu=on'
2019-04-07 18:25:55 +03:00
@tar -C $( PWD) /build -Sczf $( PWD) /build/$@ .tar.gz disk.raw
2019-04-06 17:24:50 +03:00
@rm $( PWD) /build/disk.raw
2019-04-05 07:34:58 +03:00
2019-05-03 07:30:06 +03:00
.PHONY : image -iso
image-iso : installer
@docker run --rm -it -v $( PWD) /build:/out autonomy/installer:$( TAG) iso
2019-04-30 20:21:51 +03:00
.PHONY : talos -aws
talos-aws : installer
@docker run \
--rm \
-i \
-e AWS_ACCESS_KEY_ID = $( AWS_ACCESS_KEY_ID) \
-e AWS_SECRET_ACCESS_KEY = $( AWS_SECRET_ACCESS_KEY) \
-e AWS_DEFAULT_REGION = $( AWS_DEFAULT_REGION) \
autonomy/installer:$( TAG) ami -var regions = ${ AWS_REGIONS }
2019-04-19 05:31:43 +03:00
.PHONY : talos -raw
2019-04-07 18:25:55 +03:00
talos-raw : installer
@docker run --rm -v /dev:/dev -v $( PWD) /build:/out --privileged $( DOCKER_ARGS) autonomy/installer:$( TAG) disk -n rootfs -l
2019-04-05 07:34:58 +03:00
2019-04-19 05:31:43 +03:00
.PHONY : talos
2019-04-05 07:34:58 +03:00
talos : buildkitd
2019-04-24 04:52:31 +03:00
@$( BINDIR) /buildctl --addr $( BUILDKIT_HOST) \
2019-04-05 07:34:58 +03:00
build \
2019-04-24 04:52:31 +03:00
--output type = docker,dest= build/$@ .tar,name= docker.io/autonomy/$@ :$( TAG) \
--opt target = $@ \
2019-04-05 07:34:58 +03:00
$( COMMON_ARGS)
@docker load < build/$@ .tar
2019-02-19 19:41:41 +03:00
2019-04-28 22:06:03 +03:00
.PHONY : integration
integration :
@KUBERNETES_VERSION= v1.14.1 ./hack/test/integration.sh
2019-04-19 05:31:43 +03:00
.PHONY : test
test : buildkitd
2019-04-14 19:27:20 +03:00
@mkdir -p build
2019-04-24 04:52:31 +03:00
@$( BINDIR) /buildctl --addr $( BUILDKIT_HOST) \
2019-02-15 07:32:00 +03:00
build \
2019-04-24 04:52:31 +03:00
--output type = docker,dest= /tmp/$@ .tar,name= docker.io/autonomy/$@ :$( TAG) \
--opt target = $@ \
2019-01-19 12:58:26 +03:00
$( COMMON_ARGS)
2019-04-19 05:31:43 +03:00
@docker load < /tmp/$@ .tar
2019-04-14 19:27:20 +03:00
@docker run -i --rm $( DOCKER_TEST_ARGS) autonomy/$@ :$( TAG) /bin/test.sh --short
@trap "rm -rf ./.artifacts" EXIT; mkdir -p ./.artifacts && \
docker run -i --rm $( DOCKER_TEST_ARGS) -v $( PWD) /.artifacts:/src/artifacts autonomy/$@ :$( TAG) /bin/test.sh && \
cp ./.artifacts/coverage.txt coverage.txt
2018-12-20 09:22:05 +03:00
2019-04-19 05:31:43 +03:00
.PHONY : dev -test
2019-04-16 00:41:11 +03:00
dev-test :
@docker run -i --rm $( DOCKER_TEST_ARGS) \
-v $( PWD) /internal:/src/internal:ro \
-v $( PWD) /pkg:/src/pkg:ro \
-v $( PWD) /cmd:/src/cmd:ro \
autonomy/test:$( TAG) \
go test -v ./...
2019-04-19 05:31:43 +03:00
.PHONY : lint
2019-02-28 05:57:35 +03:00
lint : buildkitd
2019-04-24 04:52:31 +03:00
@$( BINDIR) /buildctl --addr $( BUILDKIT_HOST) \
2019-02-15 07:32:00 +03:00
build \
2019-04-24 04:52:31 +03:00
--opt target = $@ \
2019-01-19 12:58:26 +03:00
$( COMMON_ARGS)
2019-04-19 05:31:43 +03:00
.PHONY : osctl -linux -amd 64
2019-02-28 05:57:35 +03:00
osctl-linux-amd64 : buildkitd
2019-04-24 04:52:31 +03:00
@$( BINDIR) /buildctl --addr $( BUILDKIT_HOST) \
2019-02-15 07:32:00 +03:00
build \
2019-04-24 04:52:31 +03:00
--output type = local,dest= build \
--opt target = $@ \
2019-01-19 12:58:26 +03:00
$( COMMON_ARGS)
2019-04-19 05:31:43 +03:00
.PHONY : osctl -darwin -amd 64
2019-02-28 05:57:35 +03:00
osctl-darwin-amd64 : buildkitd
2019-04-24 04:52:31 +03:00
@$( BINDIR) /buildctl --addr $( BUILDKIT_HOST) \
2019-02-15 07:32:00 +03:00
build \
2019-04-24 04:52:31 +03:00
--output type = local,dest= build \
--opt target = $@ \
2019-01-19 12:58:26 +03:00
$( COMMON_ARGS)
2019-04-19 05:31:43 +03:00
.PHONY : osinstall -linux -amd 64
2019-02-28 05:57:35 +03:00
osinstall-linux-amd64 : buildkitd
2019-04-24 04:52:31 +03:00
@$( BINDIR) /buildctl --addr $( BUILDKIT_HOST) \
2019-02-24 00:18:52 +03:00
build \
2019-04-24 04:52:31 +03:00
--output type = local,dest= build \
--opt target = $@ \
2019-02-24 00:18:52 +03:00
$( COMMON_ARGS)
2019-04-19 05:31:43 +03:00
.PHONY : udevd
2019-02-28 05:57:35 +03:00
udevd : buildkitd
2019-04-24 04:52:31 +03:00
@$( BINDIR) /buildctl --addr $( BUILDKIT_HOST) \
2019-02-15 07:32:00 +03:00
build \
2019-04-30 18:48:48 +03:00
--output type = docker,dest= images/$@ .tar,name= docker.io/autonomy/$@ :$( TAG) \
2019-04-24 04:52:31 +03:00
--opt target = $@ \
2019-01-19 12:58:26 +03:00
$( COMMON_ARGS)
2019-04-19 05:31:43 +03:00
.PHONY : osd
2019-04-04 09:07:49 +03:00
osd : buildkitd images
2019-04-24 04:52:31 +03:00
@$( BINDIR) /buildctl --addr $( BUILDKIT_HOST) \
2019-02-15 07:32:00 +03:00
build \
2019-04-24 04:52:31 +03:00
--output type = docker,dest= images/$@ .tar,name= docker.io/autonomy/$@ :$( TAG) \
--opt target = $@ \
2019-01-19 12:58:26 +03:00
$( COMMON_ARGS)
2019-04-19 05:31:43 +03:00
.PHONY : trustd
2019-04-04 09:07:49 +03:00
trustd : buildkitd images
2019-04-24 04:52:31 +03:00
@$( BINDIR) /buildctl --addr $( BUILDKIT_HOST) \
2019-02-15 07:32:00 +03:00
build \
2019-04-24 04:52:31 +03:00
--output type = docker,dest= images/$@ .tar,name= docker.io/autonomy/$@ :$( TAG) \
--opt target = $@ \
2019-01-19 12:58:26 +03:00
$( COMMON_ARGS)
2019-04-19 05:31:43 +03:00
.PHONY : proxyd
2019-04-04 09:07:49 +03:00
proxyd : buildkitd images
2019-04-24 04:52:31 +03:00
@$( BINDIR) /buildctl --addr $( BUILDKIT_HOST) \
2019-02-15 07:32:00 +03:00
build \
2019-04-24 04:52:31 +03:00
--output type = docker,dest= images/$@ .tar,name= docker.io/autonomy/$@ :$( TAG) \
--opt target = $@ \
2019-01-19 12:58:26 +03:00
$( COMMON_ARGS)
2019-04-19 05:31:43 +03:00
.PHONY : ntpd
2019-04-04 09:07:49 +03:00
ntpd : buildkitd images
2019-04-24 04:52:31 +03:00
@$( BINDIR) /buildctl --addr $( BUILDKIT_HOST) \
2019-03-24 01:58:13 +03:00
build \
2019-04-24 04:52:31 +03:00
--output type = docker,dest= images/$@ .tar,name= docker.io/autonomy/$@ :$( TAG) \
--opt target = $@ \
2019-03-24 01:58:13 +03:00
$( COMMON_ARGS)
2019-04-19 05:31:43 +03:00
images :
@mkdir images
2019-01-16 05:46:41 +03:00
2019-04-12 09:40:30 +03:00
.PHONY : login
login :
@docker login --username " $( DOCKER_USERNAME) " --password " $( DOCKER_PASSWORD) "
2019-04-19 05:31:43 +03:00
.PHONY : push
2019-04-12 09:40:30 +03:00
push :
@docker tag autonomy/installer:$( TAG) autonomy/installer:latest
@docker push autonomy/installer:$( TAG)
@docker push autonomy/installer:latest
@docker tag autonomy/talos:$( TAG) autonomy/talos:latest
@docker push autonomy/talos:$( TAG)
@docker push autonomy/talos:latest
2019-04-19 05:31:43 +03:00
.PHONY : clean
2018-12-20 09:22:05 +03:00
clean :
2019-04-05 07:34:58 +03:00
@-rm -rf build images vendor