Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactor docker/* targets in Makefile
Browse files Browse the repository at this point in the history
Signed-off-by: Gábor Lipták <gliptak@gmail.com>
gliptak committed Mar 7, 2024
1 parent bb48f38 commit 8370810
Showing 2 changed files with 42 additions and 39 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build-images.yml
Original file line number Diff line number Diff line change
@@ -28,4 +28,4 @@ jobs:
docker version -f '{{.Server.Experimental}}'
- name: build_docker
run: make build_prod_images
run: make build/docker
79 changes: 41 additions & 38 deletions Makefile
Original file line number Diff line number Diff line change
@@ -31,7 +31,7 @@ help: ## Display this help
# This recipe builds and pushes images for production. Note: RELEASE_TAG must be set
#
.PHONY: cloudbuild
cloudbuild: require_release_tag push_prod_images ## Build and push images
cloudbuild: require_release_tag docker/push/prod_images ## Build and push images

.PHONY: require_release_tag
require_release_tag:
@@ -43,78 +43,81 @@ endif
#
# These recipes build all the top-level docker images

build_%_image:
docker/build/%_image:
@# if TAG is 'latest', the two -t arguments are equivalent and do the same thing
docker build $(BUILD_ARG) -t ${REGISTRY}/$(IMAGE_NAME) -t ${REGISTRY}/$(IMAGE_NAME):$(TAG) -f $(DOCKERFILE) $(DIR)

#
# These recipes build the sandbox images.
#
build_%_sandbox:
docker/build/%_sandbox:
@# if TAG is 'latest', the two -t arguments are equivalent and do the same thing
docker build -t ${REGISTRY}/$(IMAGE_NAME) -t ${REGISTRY}/$(IMAGE_NAME):$(TAG) -f $(DOCKERFILE) $(DIR)

build_analysis_image: DIR=$(PREFIX)
build_analysis_image: DOCKERFILE=$(PREFIX)/cmd/analyze/Dockerfile
build_analysis_image: IMAGE_NAME=analysis
docker/build/analysis_image: DIR=$(PREFIX)
docker/build/analysis_image: DOCKERFILE=$(PREFIX)/cmd/analyze/Dockerfile
docker/build/analysis_image: IMAGE_NAME=analysis

build_scheduler_image: DIR=$(PREFIX)
build_scheduler_image: DOCKERFILE=$(PREFIX)/cmd/scheduler/Dockerfile
build_scheduler_image: IMAGE_NAME=scheduler
docker/build/scheduler_image: DIR=$(PREFIX)
docker/build/scheduler_image: DOCKERFILE=$(PREFIX)/cmd/scheduler/Dockerfile
docker/build/scheduler_image: IMAGE_NAME=scheduler

build_static_analysis_sandbox: DIR=$(PREFIX)
build_static_analysis_sandbox: DOCKERFILE=$(SANDBOX_DIR)/staticanalysis/Dockerfile
build_static_analysis_sandbox: IMAGE_NAME=static-analysis
docker/build/static_analysis_sandbox: DIR=$(PREFIX)
docker/build/static_analysis_sandbox: DOCKERFILE=$(SANDBOX_DIR)/staticanalysis/Dockerfile
docker/build/static_analysis_sandbox: IMAGE_NAME=static-analysis

build_dynamic_analysis_sandbox: DIR=$(SANDBOX_DIR)/dynamicanalysis
build_dynamic_analysis_sandbox: DOCKERFILE=$(SANDBOX_DIR)/dynamicanalysis/Dockerfile
build_dynamic_analysis_sandbox: IMAGE_NAME=dynamic-analysis
docker/build/dynamic_analysis_sandbox: DIR=$(SANDBOX_DIR)/dynamicanalysis
docker/build/dynamic_analysis_sandbox: DOCKERFILE=$(SANDBOX_DIR)/dynamicanalysis/Dockerfile
docker/build/dynamic_analysis_sandbox: IMAGE_NAME=dynamic-analysis

.PHONY: build_prod_images
build_prod_images: build_dynamic_analysis_sandbox build_static_analysis_sandbox build_analysis_image build_scheduler_image ## Build images
.PHONY: build/docker
build/docker: docker/build/dynamic_analysis_sandbox docker/build/static_analysis_sandbox docker/build/analysis_image docker/build/scheduler_image ## Build images

#
# Builds then pushes analysis and sandbox images
#

push_%:
docker/push/%_image:
docker push --all-tags ${REGISTRY}/$(IMAGE_NAME)

push_analysis_image: IMAGE_NAME=analysis
push_analysis_image: build_analysis_image
docker/push/%_sandbox:
docker push --all-tags ${REGISTRY}/$(IMAGE_NAME)

docker/push/analysis_image: IMAGE_NAME=analysis
docker/push/analysis_image: docker/build/analysis_image

push_scheduler_image: IMAGE_NAME=scheduler
push_scheduler_image: build_scheduler_image
docker/push/scheduler_image: IMAGE_NAME=scheduler
docker/push/scheduler_image: docker/build/scheduler_image

push_dynamic_analysis_sandbox: IMAGE_NAME=dynamic-analysis
push_dynamic_analysis_sandbox: build_dynamic_analysis_sandbox
docker/push/dynamic_analysis_sandbox: IMAGE_NAME=dynamic-analysis
docker/push/dynamic_analysis_sandbox: docker/build/dynamic_analysis_sandbox

push_static_analysis_sandbox: IMAGE_NAME=static-analysis
push_static_analysis_sandbox: build_static_analysis_sandbox
docker/push/static_analysis_sandbox: IMAGE_NAME=static-analysis
docker/push/static_analysis_sandbox: docker/build/static_analysis_sandbox

.PHONY: push_prod_sandboxes
push_prod_sandboxes: push_dynamic_analysis_sandbox push_static_analysis_sandbox
.PHONY: docker/push/prod_sandboxes
docker/push/prod_sandboxes: docker/push/dynamic_analysis_sandbox docker/push/static_analysis_sandbox

.PHONY: push_prod_images
push_prod_images: push_prod_sandboxes push_analysis_image push_scheduler_image ## Push production images
.PHONY: docker/push/prod_images
docker/push/prod_images: docker/push/prod_sandboxes docker/push/analysis_image docker/push/scheduler_image ## Push production images


#
# These update (sync) locally built sandbox images from Docker to
# podman. In order to use locally built sandbox images for analysis,
# pass '-nopull' to scripts/run_analysis.sh
#
sync_%_sandbox:
docker/sync/%_sandbox:
docker save ${REGISTRY}/${IMAGE_NAME}:$(TAG) | sudo podman load

sync_dynamic_analysis_sandbox: IMAGE_NAME=dynamic-analysis
sync_dynamic_analysis_sandbox: build_dynamic_analysis_sandbox
docker/sync/dynamic_analysis_sandbox: IMAGE_NAME=dynamic-analysis
docker/sync/dynamic_analysis_sandbox: docker/build/dynamic_analysis_sandbox

sync_static_analysis_sandbox: IMAGE_NAME=static-analysis
sync_static_analysis_sandbox: build_static_analysis_sandbox
docker/sync/static_analysis_sandbox: IMAGE_NAME=static-analysis
docker/sync/static_analysis_sandbox: docker/build/static_analysis_sandbox

.PHONY: sync_prod_sandboxes
sync_prod_sandboxes: sync_dynamic_analysis_sandbox sync_static_analysis_sandbox
.PHONY: docker/sync/prod_sandboxes
docker/sync/prod_sandboxes: docker/sync/dynamic_analysis_sandbox docker/sync/static_analysis_sandbox


#
@@ -175,7 +178,7 @@ e2e_test_logs_analysis:

.PHONY: build_e2e_test_images
build_e2e_test_images: TAG=test
build_e2e_test_images: sync_prod_sandboxes build_analysis_image build_scheduler_image
build_e2e_test_images: docker/sync/prod_sandboxes docker/build/analysis_image docker/build/scheduler_image



0 comments on commit 8370810

Please sign in to comment.