Implemented the docker build and housekeeping workflows in the Makefile file.
This commit is contained in:
parent
d7e5123b5e
commit
58a3fc9ff7
51
Makefile
Normal file
51
Makefile
Normal file
@ -0,0 +1,51 @@
|
|||||||
|
# --- IMPORTS ---
|
||||||
|
|
||||||
|
# Imports environment variables.
|
||||||
|
environment_vars ?= .env
|
||||||
|
|
||||||
|
include $(environment_vars)
|
||||||
|
export $(shell sed 's/=.*//' $(environment_vars))
|
||||||
|
|
||||||
|
# --- ARGUMENTS ---
|
||||||
|
|
||||||
|
override tag?=${DOCKER_IMAGE_TAG}
|
||||||
|
override platform?=${DOCKER_IMAGE_PLATFORM}
|
||||||
|
override config?=${SWIFT_BUILD_CONFIGURATION}
|
||||||
|
|
||||||
|
# --- BUILDING ---
|
||||||
|
|
||||||
|
build: build-image remove-image ## Build this package against a Swift docker instance.
|
||||||
|
|
||||||
|
build-image:
|
||||||
|
@docker run \
|
||||||
|
--rm \
|
||||||
|
--volume ${PWD}:${DOCKER_VOLUME_TARGET} \
|
||||||
|
--workdir ${DOCKER_VOLUME_TARGET} \
|
||||||
|
--platform ${platform} \
|
||||||
|
${DOCKER_IMAGE_NAME}:${tag} \
|
||||||
|
swift build --configuration ${config}
|
||||||
|
|
||||||
|
remove-image:
|
||||||
|
@docker rmi ${DOCKER_IMAGE_NAME}:${tag}
|
||||||
|
|
||||||
|
# --- HOUSEKEEPING ---
|
||||||
|
|
||||||
|
remove-images: ## Remove all outstanding Swift docker images.
|
||||||
|
@docker images --all | grep ${DOCKER_IMAGE_NAME} | awk '{print $$3}' | xargs docker rmi --force
|
||||||
|
|
||||||
|
clean: ## Clean the build artifacts for the package.
|
||||||
|
@swift package clean
|
||||||
|
|
||||||
|
reset: ## Reset the build folder for the package.
|
||||||
|
@swift package reset
|
||||||
|
|
||||||
|
# --- HELP ---
|
||||||
|
|
||||||
|
# Outputs the documentation for each of the defined tasks when `help` is called.
|
||||||
|
# Reference: https://marmelab.com/blog/2016/02/29/auto-documented-makefile.html
|
||||||
|
.PHONY: help
|
||||||
|
|
||||||
|
help: ## Prints the written documentation for all the defined tasks.
|
||||||
|
@awk 'BEGIN {FS = ":.*?## "} /^[a-zA-Z_-]+:.*?## / {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}' $(MAKEFILE_LIST)
|
||||||
|
|
||||||
|
.DEFAULT_GOAL := help
|
Loading…
x
Reference in New Issue
Block a user