2019-08-26 22:16:07 +00:00
TOOLS ?= autonomy/tools:a9fa749
2019-04-18 19:31:43 -07:00
# TODO(andrewrynhard): Move this logic to a shell script.
2019-08-01 00:47:55 +03:00
BUILDKIT_VERSION ?= v0.6.0
2019-08-14 18:00:25 +00:00
KUBECTL_VERSION ?= v1.16.0-alpha.3
2019-08-07 01:08:27 +03:00
GO_VERSION ?= 1.12
2019-02-14 22:32:00 -06:00
BUILDKIT_IMAGE ?= moby/buildkit:$( BUILDKIT_VERSION)
BUILDKIT_HOST ?= tcp://0.0.0.0:1234
BUILDKIT_CONTAINER_NAME ?= talos-buildkit
2019-02-15 09:57:27 -06: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 11:51:39 -07:00
2019-02-14 22:32:00 -06: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 13:08:01 -05:00
BUILDKIT_CACHE ?= -v $( HOME) /.buildkit:/var/lib/buildkit
2019-02-14 22:32:00 -06: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-06-05 11:44:15 -07:00
BUILDKIT_CACHE ?=
2019-02-14 22:32:00 -06:00
e n d i f
2019-04-23 20:52:31 -05:00
2019-04-29 11:51:39 -07: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-06-05 11:44:15 -07:00
i f e q ( $( UNAME_S ) , L i n u x )
2019-07-04 23:46:55 +03:00
GITMETA := https://github.com/talos-systems/gitmeta/releases/download/v0.1.0-alpha.2/gitmeta-linux-amd64
2019-06-05 11:44:15 -07:00
e n d i f
i f e q ( $( UNAME_S ) , D a r w i n )
2019-07-04 23:46:55 +03:00
GITMETA := https://github.com/talos-systems/gitmeta/releases/download/v0.1.0-alpha.2/gitmeta-darwin-amd64
2019-06-05 11:44:15 -07:00
e n d i f
2019-04-23 20:52:31 -05:00
BINDIR ?= ./bin
CONFORM_VERSION ?= 57c9dbd
2019-07-15 15:00:31 -04:00
SHA ?= $( shell $( BINDIR) /gitmeta git sha)
TAG ?= $( shell $( BINDIR) /gitmeta image tag)
2019-08-17 15:21:20 -05:00
BRANCH ?= $( shell $( BINDIR) /gitmeta git branch)
2019-06-05 11:44:15 -07:00
2019-04-23 20:52:31 -05:00
COMMON_ARGS = --progress= plain
COMMON_ARGS += --frontend= dockerfile.v0
2019-07-18 23:05:26 +03:00
COMMON_ARGS += --allow security.insecure
2019-04-23 20:52:31 -05:00
COMMON_ARGS += --local context = .
COMMON_ARGS += --local dockerfile = .
2019-07-13 00:24:51 +00:00
COMMON_ARGS += --opt build-arg:TOOLS= $( TOOLS)
2019-04-23 20:52:31 -05:00
COMMON_ARGS += --opt build-arg:SHA= $( SHA)
COMMON_ARGS += --opt build-arg:TAG= $( TAG)
2019-08-07 01:08:27 +03:00
COMMON_ARGS += --opt build-arg:GO_VERSION= $( GO_VERSION)
2019-04-23 20:52:31 -05:00
DOCKER_ARGS ?=
2018-12-19 22:22:05 -08:00
2019-07-23 17:17:16 +03:00
TESTPKGS ?= ./...
2019-08-10 21:29:25 +00:00
all : ci rootfs initramfs kernel osctl -linux osctl -darwin installer container
2019-04-29 11:25:04 -05:00
.PHONY : ci
ci : builddeps buildkitd
2019-02-14 22:32:00 -06:00
.PHONY : builddeps
builddeps : gitmeta buildctl
2019-06-05 11:44:15 -07:00
gitmeta : $( BINDIR ) /gitmeta
$(BINDIR)/gitmeta :
@mkdir -p $( BINDIR)
@curl -L $( GITMETA) -o $( BINDIR) /gitmeta
@chmod +x $( BINDIR) /gitmeta
2019-02-14 22:32:00 -06:00
2019-04-23 20:52:31 -05:00
buildctl : $( BINDIR ) /buildctl
$(BINDIR)/buildctl :
2019-04-29 11:25:04 -05:00
@mkdir -p $( BINDIR)
2019-04-29 11:51:39 -07: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-14 22:32:00 -06: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-14 22:32:00 -06:00
$( BUILDKIT_IMAGE) \
2019-07-18 23:05:26 +03:00
--addr $( BUILDKIT_HOST) \
--allow-insecure-entitlement security.insecure
2019-02-15 09:57:27 -06:00
@echo "Wait for buildkitd to become available"
@sleep 5
2019-02-14 22:32:00 -06:00
e n d i f
e n d i f
2019-04-23 20:52:31 -05: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-08-09 03:45:13 +00:00
.PHONY : generate
generate : buildkitd
$( BINDIR) /buildctl --addr $( BUILDKIT_HOST) \
build \
2019-08-16 23:26:08 -05:00
--output type = local,dest= ./ \
2019-08-09 03:45:13 +00:00
--opt target = $@ \
$( COMMON_ARGS)
2019-04-18 19:31:43 -07:00
.PHONY : kernel
2019-02-28 03:57:35 +01:00
kernel : buildkitd
2019-04-23 20:52:31 -05:00
@$( BINDIR) /buildctl --addr $( BUILDKIT_HOST) \
2019-02-14 22:32:00 -06:00
build \
2019-08-16 23:26:08 -05:00
--output type = local,dest= build \
2019-04-23 20:52:31 -05:00
--opt target = $@ \
2019-01-19 01:58:26 -08:00
$( COMMON_ARGS)
2019-04-15 22:44:59 -07:00
@-rm -rf ./build/modules
2019-01-17 19:14:52 -08:00
2019-04-18 19:31:43 -07:00
.PHONY : initramfs
2019-02-28 03:57:35 +01:00
initramfs : buildkitd
2019-04-23 20:52:31 -05:00
@$( BINDIR) /buildctl --addr $( BUILDKIT_HOST) \
2019-02-14 22:32:00 -06:00
build \
2019-08-16 23:26:08 -05:00
--output type = local,dest= build \
2019-04-23 20:52:31 -05:00
--opt target = $@ \
2019-01-19 01:58:26 -08:00
$( COMMON_ARGS)
2018-12-19 22:22:05 -08:00
2019-04-18 19:31:43 -07:00
.PHONY : rootfs
2019-08-02 16:08:24 -05:00
rootfs : buildkitd osd trustd proxyd ntpd networkd
2019-04-23 20:52:31 -05:00
@$( BINDIR) /buildctl --addr $( BUILDKIT_HOST) \
2019-02-14 22:32:00 -06:00
build \
2019-04-23 20:52:31 -05:00
--opt target = $@ \
2019-01-19 01:58:26 -08:00
$( COMMON_ARGS)
2018-12-19 22:22:05 -08:00
2019-04-18 19:31:43 -07:00
.PHONY : installer
2019-02-28 03:57:35 +01:00
installer : buildkitd
@mkdir -p build
2019-04-23 20:52:31 -05:00
@$( BINDIR) /buildctl --addr $( BUILDKIT_HOST) \
2019-02-14 22:32:00 -06:00
build \
2019-04-23 20:52:31 -05:00
--output type = docker,dest= build/$@ .tar,name= docker.io/autonomy/$@ :$( TAG) \
--opt target = $@ \
2019-01-19 01:58:26 -08:00
$( COMMON_ARGS)
@docker load < build/$@ .tar
2019-02-19 11:41:41 -05:00
2019-08-09 03:45:13 +00:00
.PHONY : image -aws
image-aws :
2019-04-30 10:21:51 -07:00
@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) \
2019-05-09 13:04:41 -07:00
autonomy/installer:$( TAG) ami -var regions = ${ AWS_PUBLISH_REGIONS } -var visibility = all
2019-04-30 10:21:51 -07:00
2019-08-09 03:45:13 +00:00
.PHONY : image -azure
image-azure :
2019-07-27 08:09:50 +00:00
@docker run --rm -v /dev:/dev -v $( PWD) /build:/out \
--privileged $( DOCKER_ARGS) \
autonomy/installer:$( TAG) \
install \
2019-08-09 03:45:13 +00:00
-n azure \
2019-07-27 08:09:50 +00:00
-r \
-p azure \
-u none \
-e rootdelay = 300
@docker run --rm -v $( PWD) /build:/out $( DOCKER_ARGS) \
--entrypoint qemu-img \
autonomy/installer:$( TAG) \
convert \
-f raw \
-o subformat = fixed,force_size \
2019-08-09 03:45:13 +00:00
-O vpc /out/azure.raw /out/azure.vhd
@tar -C $( PWD) /build -czf $( PWD) /build/azure.tar.gz azure.vhd
@rm -rf $( PWD) /build/azure.raw $( PWD) /build/azure.vhd
.PHONY : push -image -azure
push-image-azure :
2019-08-12 19:24:12 +00:00
@TAG= $( TAG) ./hack/test/azure-setup.sh
2019-07-27 08:09:50 +00:00
2019-08-11 21:38:24 +00:00
.PHONY : image -gcp
image-gcp :
2019-08-16 23:26:08 -05:00
@docker run --rm -v /dev:/dev -v $( PWD) /build:/out \
--privileged $( DOCKER_ARGS) \
autonomy/installer:$( TAG) \
install \
-n disk \
-r \
2019-08-11 21:38:24 +00:00
-p gcp \
2019-08-16 23:26:08 -05:00
-u none
2019-08-11 21:38:24 +00:00
@tar -C $( PWD) /build -czf $( PWD) /build/gcp.tar.gz disk.raw
2019-08-09 03:45:13 +00:00
2019-08-11 21:38:24 +00:00
.PHONY : push -image -gcp
push-image-gcp :
@TAG= $( TAG) ./hack/test/gcp-setup.sh
2019-08-09 03:45:13 +00:00
2019-08-11 17:29:45 +00:00
.PHONY : image -test
image-test :
@docker run --rm -v /dev:/dev -v /tmp:/out --privileged $( DOCKER_ARGS) autonomy/installer:$( TAG) install -n test -r -p test -u none
2019-04-04 21:34:58 -07:00
2019-08-09 03:45:13 +00:00
.PHONY : iso
iso :
@docker run --rm -i -v $( PWD) /build:/out autonomy/installer:$( TAG) iso
.PHONY : container
container : buildkitd
2019-04-23 20:52:31 -05:00
@$( BINDIR) /buildctl --addr $( BUILDKIT_HOST) \
2019-04-04 21:34:58 -07:00
build \
2019-08-09 03:45:13 +00:00
--output type = docker,dest= build/$@ .tar,name= docker.io/autonomy/talos:$( TAG) \
2019-04-23 20:52:31 -05:00
--opt target = $@ \
2019-04-04 21:34:58 -07:00
$( COMMON_ARGS)
@docker load < build/$@ .tar
2019-02-19 11:41:41 -05:00
2019-06-21 23:05:17 -07:00
.PHONY : basic -integration
basic-integration :
2019-07-29 16:11:09 -04:00
@TAG= $( TAG) ./hack/test/$@ .sh
2019-04-28 12:06:03 -07:00
2019-08-09 03:45:13 +00:00
.PHONY : capi
capi :
2019-08-02 11:05:34 -04:00
@TAG= $( TAG) ./hack/test/$@ .sh
2019-08-09 03:45:13 +00:00
.PHONY : e 2e -integration
2019-06-21 23:05:17 -07:00
e2e-integration :
2019-07-29 16:11:09 -04:00
@TAG= $( TAG) ./hack/test/$@ .sh
2019-06-17 12:36:48 -04:00
2019-08-09 03:45:13 +00:00
.PHONY : unit -tests
unit-tests : buildkitd
2019-07-04 08:43:34 -07:00
@$( BINDIR) /buildctl --addr $( BUILDKIT_HOST) \
build \
2019-07-06 06:20:24 +00:00
--opt target = $@ \
2019-07-18 23:05:26 +03:00
--output type = local,dest= ./ \
2019-07-23 17:17:16 +03:00
--opt build-arg:TESTPKGS= $( TESTPKGS) \
2019-08-07 01:08:27 +03:00
$( COMMON_ARGS)
2019-08-09 03:45:13 +00:00
.PHONY : unit -tests -race
unit-tests-race : buildkitd
2019-08-07 01:08:27 +03:00
@$( BINDIR) /buildctl --addr $( BUILDKIT_HOST) \
build \
--opt target = $@ \
--opt build-arg:TESTPKGS= $( TESTPKGS) \
2019-07-04 08:43:34 -07:00
$( COMMON_ARGS)
2019-04-16 00:41:11 +03:00
2019-04-18 19:31:43 -07:00
.PHONY : lint
2019-02-28 03:57:35 +01:00
lint : buildkitd
2019-04-23 20:52:31 -05:00
@$( BINDIR) /buildctl --addr $( BUILDKIT_HOST) \
2019-02-14 22:32:00 -06:00
build \
2019-04-23 20:52:31 -05:00
--opt target = $@ \
2019-01-19 01:58:26 -08:00
$( COMMON_ARGS)
2019-08-27 21:45:59 +00:00
.PHONY : protolint
protolint : buildkitd
@$( BINDIR) /buildctl --addr $( BUILDKIT_HOST) \
build \
--opt target = $@ \
$( COMMON_ARGS)
2019-08-17 08:51:40 +00:00
.PHONY : markdownlint
markdownlint : buildkitd
@$( BINDIR) /buildctl --addr $( BUILDKIT_HOST) \
build \
--opt target = $@ \
$( COMMON_ARGS)
2019-07-19 17:54:03 +03:00
.PHONY : osctl -linux
2019-07-13 00:24:51 +00:00
osctl-linux : buildkitd
2019-04-23 20:52:31 -05:00
@$( BINDIR) /buildctl --addr $( BUILDKIT_HOST) \
2019-02-14 22:32:00 -06:00
build \
2019-08-16 23:26:08 -05:00
--output type = local,dest= build \
2019-04-23 20:52:31 -05:00
--opt target = $@ \
2019-01-19 01:58:26 -08:00
$( COMMON_ARGS)
2019-07-13 00:24:51 +00:00
.PHONY : osctl -darwin
osctl-darwin : buildkitd
2019-04-23 20:52:31 -05:00
@$( BINDIR) /buildctl --addr $( BUILDKIT_HOST) \
2019-02-14 22:32:00 -06:00
build \
2019-08-16 23:26:08 -05:00
--output type = local,dest= build \
2019-04-23 20:52:31 -05:00
--opt target = $@ \
2019-01-19 01:58:26 -08:00
$( COMMON_ARGS)
2019-07-16 15:09:35 +00:00
.PHONY : machined
machined : buildkitd images
@$( BINDIR) /buildctl --addr $( BUILDKIT_HOST) \
build \
--opt target = $@ \
$( COMMON_ARGS)
2019-04-18 19:31:43 -07:00
.PHONY : osd
2019-04-03 23:07:49 -07:00
osd : buildkitd images
2019-04-23 20:52:31 -05:00
@$( BINDIR) /buildctl --addr $( BUILDKIT_HOST) \
2019-02-14 22:32:00 -06:00
build \
2019-04-23 20:52:31 -05:00
--output type = docker,dest= images/$@ .tar,name= docker.io/autonomy/$@ :$( TAG) \
--opt target = $@ \
2019-01-19 01:58:26 -08:00
$( COMMON_ARGS)
2019-04-18 19:31:43 -07:00
.PHONY : trustd
2019-04-03 23:07:49 -07:00
trustd : buildkitd images
2019-04-23 20:52:31 -05:00
@$( BINDIR) /buildctl --addr $( BUILDKIT_HOST) \
2019-02-14 22:32:00 -06:00
build \
2019-04-23 20:52:31 -05:00
--output type = docker,dest= images/$@ .tar,name= docker.io/autonomy/$@ :$( TAG) \
--opt target = $@ \
2019-01-19 01:58:26 -08:00
$( COMMON_ARGS)
2019-04-18 19:31:43 -07:00
.PHONY : proxyd
2019-04-03 23:07:49 -07:00
proxyd : buildkitd images
2019-04-23 20:52:31 -05:00
@$( BINDIR) /buildctl --addr $( BUILDKIT_HOST) \
2019-02-14 22:32:00 -06:00
build \
2019-04-23 20:52:31 -05:00
--output type = docker,dest= images/$@ .tar,name= docker.io/autonomy/$@ :$( TAG) \
--opt target = $@ \
2019-01-19 01:58:26 -08:00
$( COMMON_ARGS)
2019-04-18 19:31:43 -07:00
.PHONY : ntpd
2019-04-03 23:07:49 -07:00
ntpd : buildkitd images
2019-04-23 20:52:31 -05:00
@$( BINDIR) /buildctl --addr $( BUILDKIT_HOST) \
2019-03-23 17:58:13 -05:00
build \
2019-04-23 20:52:31 -05:00
--output type = docker,dest= images/$@ .tar,name= docker.io/autonomy/$@ :$( TAG) \
--opt target = $@ \
2019-03-23 17:58:13 -05:00
$( COMMON_ARGS)
2019-08-02 16:08:24 -05:00
.PHONY : networkd
networkd : buildkitd images
@$( BINDIR) /buildctl --addr $( BUILDKIT_HOST) \
build \
--output type = docker,dest= images/$@ .tar,name= docker.io/autonomy/$@ :$( TAG) \
--opt target = $@ \
$( COMMON_ARGS)
2019-04-18 19:31:43 -07:00
images :
2019-08-10 21:29:25 +00:00
@mkdir -p images
2019-01-15 18:46:41 -08:00
2019-04-11 23:40:30 -07:00
.PHONY : login
login :
@docker login --username " $( DOCKER_USERNAME) " --password " $( DOCKER_PASSWORD) "
2019-04-18 19:31:43 -07:00
.PHONY : push
2019-08-09 03:45:13 +00:00
push : gitmeta login
2019-04-11 23:40:30 -07:00
@docker push autonomy/installer:$( TAG)
@docker push autonomy/talos:$( TAG)
2019-08-17 15:21:20 -05:00
i f e q ( $( BRANCH ) , m a s t e r )
@docker tag autonomy/installer:$( TAG) autonomy/installer:latest
@docker tag autonomy/talos:$( TAG) autonomy/talos:latest
@docker push autonomy/installer:latest
2019-04-11 23:40:30 -07:00
@docker push autonomy/talos:latest
2019-08-17 15:21:20 -05:00
e n d i f
2019-04-11 23:40:30 -07:00
2019-04-18 19:31:43 -07:00
.PHONY : clean
2018-12-19 22:22:05 -08:00
clean :
2019-04-04 21:34:58 -07:00
@-rm -rf build images vendor