Skip to content

Commit

Permalink
added option to exclude a service
Browse files Browse the repository at this point in the history
  • Loading branch information
sanderegg committed Dec 6, 2024
1 parent 9a15e0c commit 5209779
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,7 @@ DOCKER_TARGET_PLATFORMS ?= linux/amd64
comma := ,

define _docker_compose_build
$(eval INCLUDED_SERVICES := $(filter-out $(exclude), $(SERVICES_NAMES_TO_BUILD))) \
export BUILD_TARGET=$(if $(findstring -devel,$@),development,production) &&\
pushd services &&\
$(foreach service, $(SERVICES_NAMES_TO_BUILD),\
Expand All @@ -172,7 +173,7 @@ docker buildx bake \
)\
)\
$(if $(push),--push,) \
$(if $(push),--file docker-bake.hcl,) --file docker-compose-build.yml $(if $(target),$(target),) \
$(if $(push),--file docker-bake.hcl,) --file docker-compose-build.yml $(if $(target),$(target),$(INCLUDED_SERVICES)) \
$(if $(findstring -nc,$@),--no-cache,\
$(foreach service, $(SERVICES_NAMES_TO_BUILD),\
--set $(service).cache-to=type=gha$(comma)mode=max$(comma)scope=$(service) \
Expand All @@ -183,7 +184,7 @@ endef

rebuild: build-nc # alias
build build-nc: .env ## Builds production images and tags them as 'local/{service-name}:production'. For single target e.g. 'make target=webserver build'. To export to a folder: `make local-dest=/tmp/build`
# Building service$(if $(target),,s) $(target)
# Building service$(if $(target),,s) $(target) $(if $(exclude),excluding,) $(exclude)
@$(_docker_compose_build)
# List production images
@docker images --filter="reference=local/*:production"
Expand All @@ -198,7 +199,7 @@ load-images: guard-local-src ## loads images from local-src

build-devel build-devel-nc: .env ## Builds development images and tags them as 'local/{service-name}:development'. For single target e.g. 'make target=webserver build-devel'
ifeq ($(target),)
# Building services
# Building services $(if $(exclude),excluding,) $(exclude)
@$(_docker_compose_build)
else
ifeq ($(findstring static-webserver,$(target)),static-webserver)
Expand Down

0 comments on commit 5209779

Please sign in to comment.