2024-04-07 03:07:37 +00:00
|
|
|
SHELL := bash
|
|
|
|
.ONESHELL:
|
|
|
|
.SHELLFLAGS := -eu -o pipefail -c
|
|
|
|
.DELETE_ON_ERROR:
|
|
|
|
MAKEFLAGS += --warn-undefined-variables
|
|
|
|
MAKEFLAGS += --no-builtin-rules
|
|
|
|
|
|
|
|
ifeq ($(origin .RECIPEPREFIX), undefined)
|
|
|
|
$(error This Make does not support .RECIPEPREFIX. Please use GNU Make 4.0 or later)
|
2023-07-13 03:14:22 +00:00
|
|
|
endif
|
2024-04-07 03:07:37 +00:00
|
|
|
.RECIPEPREFIX = >
|
2023-07-13 03:14:22 +00:00
|
|
|
|
2024-04-07 03:07:37 +00:00
|
|
|
TARGET := tester
|
|
|
|
IMAGE_NAME := organic-test
|
|
|
|
ifneq ($(TARGET),tester)
|
|
|
|
IMAGE_NAME := $(IMAGE_NAME)-$(TARGET)
|
2023-07-13 03:14:22 +00:00
|
|
|
endif
|
|
|
|
|
2024-04-07 03:07:37 +00:00
|
|
|
.PHONY: help
|
|
|
|
help:
|
|
|
|
> @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
|
2023-07-13 03:14:22 +00:00
|
|
|
|
|
|
|
.PHONY: shell
|
2024-04-07 03:07:37 +00:00
|
|
|
shell: ## Launch an interactive shell inside the docker image with the source repository mounted at /source.
|
2023-08-27 21:51:57 +00:00
|
|
|
shell: build
|
2024-04-07 03:07:37 +00:00
|
|
|
> 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)
|
2023-09-06 19:54:25 +00:00
|
|
|
|
2024-04-07 03:07:37 +00:00
|
|
|
.PHONY: clean
|
|
|
|
clean: ## Remove the docker image and volume.
|
|
|
|
> docker rmi $(IMAGE_NAME)
|
|
|
|
> docker volume rm organic-cargo-registry
|