organic/docker/organic_development/Makefile
Tom Alexander 9f111fe445
Some checks failed
clippy Build clippy has failed
build-organic Build build-organic has failed
format Build format has failed
Rework the makefiles.
2024-04-10 20:48:11 -04:00

37 lines
1.2 KiB
Makefile

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)
endif
.RECIPEPREFIX = >
TARGET := builder
IMAGE_NAME := organic-development
ifneq ($(TARGET),builder)
IMAGE_NAME := $(IMAGE_NAME)-$(TARGET)
endif
.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
.PHONY: shell
shell: ## Launch an interactive shell inside the docker image with the source repository mounted at /source.
shell: build
> 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: clean
clean: ## Remove the docker image and volume.
> docker rmi $(IMAGE_NAME)
> docker volume rm organic-cargo-registry