Rework the makefiles.
parent
a4e433dab1
commit
9f111fe445
@ -1,44 +1,36 @@
|
|||||||
IMAGE_NAME:=organic-test
|
SHELL := bash
|
||||||
# REMOTE_REPO:=harbor.fizz.buzz/private
|
.ONESHELL:
|
||||||
|
.SHELLFLAGS := -eu -o pipefail -c
|
||||||
.PHONY: all
|
.DELETE_ON_ERROR:
|
||||||
all: build push
|
MAKEFLAGS += --warn-undefined-variables
|
||||||
|
MAKEFLAGS += --no-builtin-rules
|
||||||
.PHONY: build
|
|
||||||
build:
|
ifeq ($(origin .RECIPEPREFIX), undefined)
|
||||||
docker build -t $(IMAGE_NAME) -f Dockerfile --target tester .
|
$(error This Make does not support .RECIPEPREFIX. Please use GNU Make 4.0 or later)
|
||||||
|
|
||||||
.PHONY: build_foreign_document_test
|
|
||||||
build_foreign_document_test:
|
|
||||||
docker build -t $(IMAGE_NAME)-foreign-document -f Dockerfile --target foreign-document-test .
|
|
||||||
|
|
||||||
.PHONY: push
|
|
||||||
push:
|
|
||||||
ifdef REMOTE_REPO
|
|
||||||
docker tag $(IMAGE_NAME) $(REMOTE_REPO)/$(IMAGE_NAME)
|
|
||||||
docker push $(REMOTE_REPO)/$(IMAGE_NAME)
|
|
||||||
else
|
|
||||||
@echo "REMOTE_REPO not defined, not pushing to a remote repo."
|
|
||||||
endif
|
endif
|
||||||
|
.RECIPEPREFIX = >
|
||||||
|
|
||||||
.PHONY: clean
|
TARGET := tester
|
||||||
clean:
|
IMAGE_NAME := organic-test
|
||||||
docker rmi $(IMAGE_NAME)
|
ifneq ($(TARGET),tester)
|
||||||
ifdef REMOTE_REPO
|
IMAGE_NAME := $(IMAGE_NAME)-$(TARGET)
|
||||||
docker rmi $(REMOTE_REPO)/$(IMAGE_NAME)
|
|
||||||
else
|
|
||||||
@echo "REMOTE_REPO not defined, not removing from remote repo."
|
|
||||||
endif
|
endif
|
||||||
docker volume rm rust-cache cargo-cache
|
|
||||||
|
|
||||||
.PHONY: run
|
.PHONY: help
|
||||||
run: build
|
help:
|
||||||
docker run --rm --init --read-only --mount type=tmpfs,destination=/tmp -v "$$(readlink -f ../../):/source:ro" --workdir=/source --mount source=cargo-cache,target=/usr/local/cargo/registry --mount source=rust-cache,target=/target --env CARGO_TARGET_DIR=/target $(IMAGE_NAME) --no-default-features --features compare --no-fail-fast --lib --test test_loader
|
> @grep -h "##" $(MAKEFILE_LIST) | grep -v grep | sed -E 's/^([^:]*): *## */\1: /'
|
||||||
|
|
||||||
|
.PHONY: build
|
||||||
|
build: ## Build the docker image.
|
||||||
|
> docker build --tag $(IMAGE_NAME) --target=$(TARGET) --file Dockerfile .
|
||||||
|
> docker volume create organic-cargo-registry
|
||||||
|
|
||||||
.PHONY: shell
|
.PHONY: shell
|
||||||
|
shell: ## Launch an interactive shell inside the docker image with the source repository mounted at /source.
|
||||||
shell: build
|
shell: build
|
||||||
docker run --rm -i -t --entrypoint /bin/sh --mount type=tmpfs,destination=/tmp -v "$$(readlink -f ../../):/source:ro" --workdir=/source --mount source=cargo-cache,target=/usr/local/cargo/registry --mount source=rust-cache,target=/target --env CARGO_TARGET_DIR=/target $(IMAGE_NAME)
|
> docker run --rm -i -t --entrypoint /bin/sh --mount type=tmpfs,destination=/tmp -v "$$(readlink -f ../../):/source" --workdir=/source --env CARGO_TARGET_DIR=/target -v "organic-cargo-registry:/usr/local/cargo/registry" $(IMAGE_NAME)
|
||||||
|
|
||||||
.PHONY: run_foreign_document_test
|
.PHONY: clean
|
||||||
run_foreign_document_test: build_foreign_document_test
|
clean: ## Remove the docker image and volume.
|
||||||
docker run --rm --init --read-only --mount type=tmpfs,destination=/tmp -v "$$(readlink -f ../../):/source:ro" --workdir=/source --mount source=cargo-cache,target=/usr/local/cargo/registry --mount source=rust-cache,target=/target --env CARGO_TARGET_DIR=/target $(IMAGE_NAME)-foreign-document
|
> docker rmi $(IMAGE_NAME)
|
||||||
|
> docker volume rm organic-cargo-registry
|
||||||
|
Loading…
Reference in New Issue