-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactor Makefile structure for enhanced modularity and deployment ef…
…ficiency This commit reorganizes the build and deployment scripts by introducing separate Makefiles for the backend and frontend components, along with common utilities and informational targets. The new structure aims to improve modularity, maintainability, and clarity of the deployment process. Component-specific Makefiles handle Docker image construction and deployment more effectively, while shared utilities and variables are centralized for ease of use. Additionally, the update simplifies Docker tag generation by incorporating it directly into the Makefiles, eliminating the need for separate versioning scripts. The README has been updated to guide users through the new deployment process.
- Loading branch information
Showing
10 changed files
with
250 additions
and
204 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
common_mk := ../../scripts/govtool/common.mk | ||
ifeq ($(origin $(common_mk)), undefined) | ||
$(eval $(common_mk) := included) | ||
include $(common_mk) | ||
endif | ||
|
||
.DEFAULT_GOAL := push-backend | ||
|
||
# image tags | ||
base_backend_image_tag := $(shell git hash-object $(root_dir)/govtool/backend/vva-be.cabal) | ||
backend_image_tag := $(shell git log -n 1 --format="%H" -- $(root_dir)/govtool/backend) | ||
|
||
.PHONY: build-backend-base | ||
build-backend-base: docker-login | ||
$(call check_image_on_ecr,backend-base,$(base_backend_image_tag)) || \ | ||
$(docker) build --file $(root_dir)/govtool/backend/Dockerfile.base --tag "$(repo_url)/backend-base:$(base_backend_image_tag)" $(root_dir)/govtool/backend | ||
|
||
.PHONY: push-backend-base | ||
push-backend-base: build-backend-base | ||
$(call check_image_on_ecr,backend-base,$(base_backend_image_tag)) || \ | ||
$(docker) push $(repo_url)/backend-base:$(base_backend_image_tag) | ||
|
||
.PHONY: build-backend | ||
build-backend: build-backend-base | ||
$(call check_image_on_ecr,backend,$(backend_image_tag)) || \ | ||
$(docker) build --build-arg BASE_IMAGE_TAG=$(base_backend_image_tag) --tag "$(repo_url)/backend:$(backend_image_tag)" $(root_dir)/govtool/backend | ||
|
||
.PHONY: push-backend | ||
push-backend: push-backend-base build-backend | ||
$(call check_image_on_ecr,backend,$(backend_image_tag)) || \ | ||
$(docker) push $(repo_url)/backend:$(backend_image_tag) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
common_mk := ../../scripts/govtool/common.mk | ||
ifeq ($(origin $(common_mk)), undefined) | ||
$(eval $(common_mk) := included) | ||
include $(common_mk) | ||
endif | ||
|
||
.DEFAULT_GOAL := push-frontend | ||
|
||
# environment variables | ||
gtm_id := $(shell echo $${GTM_ID}) | ||
sentry_dsn := $(shell echo $${SENTRY_DSN}) | ||
|
||
# image tags | ||
frontend_image_tag := $(shell git log -n 1 --format="%H" -- $(root_dir)/govtool/frontend) | ||
|
||
.PHONY: build-frontend | ||
build-frontend: docker-login | ||
@:$(call check_defined, cardano_network) | ||
@:$(call check_defined, gtm_id) | ||
@:$(call check_defined, sentry_dsn) | ||
if [[ "$(cardano_network)" = "mainnet" ]]; then NETWORK_FLAG=1; else NETWORK_FLAG=0; fi; \ | ||
$(call check_image_on_ecr,frontend,$(frontend_image_tag)) || \ | ||
$(docker) build --tag "$(repo_url)/frontend:$(frontend_image_tag)" \ | ||
--build-arg VITE_BASE_URL="https://$(domain)/api" \ | ||
--build-arg VITE_GTM_ID="$(gtm_id)" \ | ||
--build-arg VITE_NETWORK_FLAG="$$NETWORK_FLAG" \ | ||
--build-arg VITE_SENTRY_DSN="$(sentry_dsn)" \ | ||
$(root_dir)/govtool/frontend | ||
|
||
.PHONY: push-frontend | ||
push-frontend: build-frontend | ||
$(call check_image_on_ecr,frontend,$(frontend_image_tag)) || \ | ||
$(docker) push $(repo_url)/frontend:$(frontend_image_tag) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.