mirror of
https://github.com/weaveworks/scope.git
synced 2026-03-05 03:01:11 +00:00
f041a74ff Undo some quoting that broke the test script (#160) b1c21a068 Merge pull request #158 from weaveworks/go-1-13 d5c7dd0cd Run shell-lint during CI, and fix warnings 6db1abd14 Update to Go 1.13.1 d6cc704a2 Fix comment 7139116ae Revert "Push comments to the left so they don't appear in scripts" e47e58f7b Push comments to the left so they don't appear in scripts 3945fcec8 Remove nonexistent env var GIT_TAG cd6299284 Merge pull request #156 from weaveworks/drop-quay af0eb5119 Merge pull request #157 from weaveworks/fix-image-tag-prefix-length 0b9aee4f2 Fix image-tag object name prefix length to 8 chars. 813c28fe7 Move from CircleCI 1.0 to 2.0 425cf4ef1 Move from quay.io to Dockerhub 87ccf4fd1 Merge pull request #155 from weaveworks/go-1-12 c31bc2865 Update lint script to work with Go 1.12 ed8e380d7 Update to Go 1.12.1 git-subtree-dir: tools git-subtree-split: f041a74ffbf273b627d6c960f17357108d0dbd1c
48 lines
1.8 KiB
Makefile
48 lines
1.8 KiB
Makefile
.PHONY: all clean images
|
|
.DEFAULT_GOAL := all
|
|
|
|
# Boiler plate for bulding Docker containers.
|
|
# All this must go at top of file I'm afraid.
|
|
IMAGE_PREFIX := weaveworks/build-
|
|
IMAGE_TAG := $(shell ../image-tag)
|
|
GIT_REVISION := $(shell git rev-parse HEAD)
|
|
UPTODATE := .uptodate
|
|
|
|
# Every directory with a Dockerfile in it builds an image called
|
|
# $(IMAGE_PREFIX)<dirname>. Dependencies (i.e. things that go in the image)
|
|
# still need to be explicitly declared.
|
|
%/$(UPTODATE): %/Dockerfile %/*
|
|
$(SUDO) docker build --build-arg=revision=$(GIT_REVISION) -t $(IMAGE_PREFIX)$(shell basename $(@D)) $(@D)/
|
|
$(SUDO) docker tag $(IMAGE_PREFIX)$(shell basename $(@D)) $(IMAGE_PREFIX)$(shell basename $(@D)):$(IMAGE_TAG)
|
|
touch $@
|
|
|
|
# Get a list of directories containing Dockerfiles
|
|
DOCKERFILES := $(shell find . -name tools -prune -o -name vendor -prune -o -type f -name 'Dockerfile' -print)
|
|
UPTODATE_FILES := $(patsubst %/Dockerfile,%/$(UPTODATE),$(DOCKERFILES))
|
|
DOCKER_IMAGE_DIRS := $(patsubst %/Dockerfile,%,$(DOCKERFILES))
|
|
IMAGE_NAMES := $(foreach dir,$(DOCKER_IMAGE_DIRS),$(patsubst %,$(IMAGE_PREFIX)%,$(shell basename $(dir))))
|
|
images:
|
|
$(info $(IMAGE_NAMES))
|
|
@echo > /dev/null
|
|
|
|
# Define imagetag-golang, etc, for each image, which parses the dockerfile and
|
|
# prints an image tag. For example:
|
|
# FROM golang:1.8.1-stretch
|
|
# in the "foo/Dockerfile" becomes:
|
|
# $ make imagetag-foo
|
|
# 1.8.1-stretch
|
|
define imagetag_dep
|
|
.PHONY: imagetag-$(1)
|
|
$(patsubst $(IMAGE_PREFIX)%,imagetag-%,$(1)): $(patsubst $(IMAGE_PREFIX)%,%,$(1))/Dockerfile
|
|
@cat $$< | grep "^FROM " | head -n1 | sed 's/FROM \(.*\):\(.*\)/\2/'
|
|
endef
|
|
$(foreach image, $(IMAGE_NAMES), $(eval $(call imagetag_dep, $(image))))
|
|
|
|
all: $(UPTODATE_FILES)
|
|
|
|
clean:
|
|
$(SUDO) docker rmi $(IMAGE_NAMES) >/dev/null 2>&1 || true
|
|
rm -rf $(UPTODATE_FILES)
|
|
|
|
|