-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #74 from yunkon-kim/241021-19
Upgrade OpenTofu and update Terrarium
- Loading branch information
Showing
38 changed files
with
839 additions
and
571 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
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 |
---|---|---|
@@ -1,23 +1,96 @@ | ||
default: | ||
cd cmd/mc-terrarium && $(MAKE) | ||
# Makefile for MC-Terrarium in Cloud-Barista. | ||
|
||
cc: | ||
cd cmd/mc-terrarium && $(MAKE) | ||
MODULE_NAME := mc-terrarium | ||
PROJECT_NAME := github.com/cloud-barista/$(MODULE_NAME) | ||
PKG_LIST := $(shell go list $(PROJECT_NAME)/... 2>&1) | ||
|
||
run: | ||
cd cmd/mc-terrarium && $(MAKE) run | ||
GOPROXY_OPTION := GOPROXY=direct # default: GOPROXY=https://proxy.golang.org,direct | ||
GO := $(GOPROXY_OPTION) go | ||
GOPATH := $(shell go env GOPATH) | ||
SWAG := ~/go/bin/swag | ||
|
||
runwithport: | ||
cd cmd/mc-terrarium && $(MAKE) runwithport --port=$(PORT) | ||
.PHONY: all dependency lint update swag swagger build arm prod run stop clean help | ||
|
||
clean: | ||
cd cmd/mc-terrarium && $(MAKE) clean | ||
all: swag build ## Default target: build the project | ||
|
||
prod: | ||
cd cmd/mc-terrarium && $(MAKE) prod | ||
dependency: ## Get dependencies | ||
@echo "Checking dependencies..." | ||
@$(GO) mod tidy | ||
@echo "Checked!" | ||
|
||
source-model: | ||
cd pkg/api/rest/model && $(MAKE) source-model | ||
lint: dependency ## Lint the files | ||
@echo "Running linter..." | ||
@if [ ! -f "$(GOPATH)/bin/golangci-lint" ] && [ ! -f "$(shell go env GOROOT)/bin/golangci-lint" ]; then \ | ||
$(GO) install github.com/golangci/golangci-lint/cmd/golangci-lint@v1.60.2; \ | ||
fi | ||
@golangci-lint run -E contextcheck -D unused | ||
@echo "Linter finished!" | ||
|
||
swag swagger: | ||
cd pkg/ && $(MAKE) swag | ||
update: ## Update all module dependencies | ||
@echo "Updating dependencies..." | ||
@cd cmd/$(MODULE_NAME) && $(GO) get -u | ||
@echo "Checking dependencies..." | ||
@$(GO) mod tidy | ||
@echo "Updated!" | ||
|
||
swag swagger: ## Generate Swagger API documentation | ||
@echo "Generating Swagger API documentation..." | ||
@ln -sf cmd/$(MODULE_NAME)/main.go ./main.go | ||
@$(SWAG) i --parseDependency --parseInternal --generalInfo ./main.go --dir ./ --output ./api | ||
@rm ./main.go | ||
@echo "Generated Swagger API documentation!" | ||
|
||
# build: lint swag ## Build the binary file for amd64 | ||
build: ## Build the binary file for amd64 | ||
@echo "Building the binary for amd64..." | ||
@cd cmd/$(MODULE_NAME) && CGO_ENABLED=0 GOOS=linux GOARCH=amd64 $(GO) build -o $(MODULE_NAME) main.go | ||
@echo "Build finished!" | ||
|
||
# arm: lint swag ## Build the binary file for ARM | ||
arm: ## Build the binary file for ARM | ||
@echo "Building the binary for ARM..." | ||
@cd cmd/$(MODULE_NAME) && CGO_ENABLED=0 GOOS=linux GOARCH=arm $(GO) build -o $(MODULE_NAME)-arm main.go | ||
@echo "Build finished!" | ||
|
||
# prod: lint swag ## Build the binary file for production | ||
prod: ## Build the binary file for production | ||
@echo "Building the binary for amd64 production..." | ||
# Note - Using cgo write normal Go code that imports a pseudo-package "C". I may not need on cross-compiling. | ||
# Note - You can find possible platforms by 'go tool dist list' for GOOS and GOARCH | ||
# Note - Using the -ldflags parameter can help set variable values at compile time. | ||
# Note - Using the -s and -w linker flags can strip the debugging information. | ||
@cd cmd/$(MODULE_NAME) && CGO_ENABLED=0 GOOS=linux GOARCH=amd64 $(GO) build -ldflags '-s -w' -tags $(MODULE_NAME) -v -o $(MODULE_NAME) main.go | ||
@echo "Build finished!" | ||
|
||
run: build ## Run the built binary | ||
@echo "Running the binary..." | ||
@source conf/setup.env; \ | ||
cd cmd/$(MODULE_NAME) && \ | ||
(./$(MODULE_NAME) || { echo "Trying with sudo..."; sudo ./$(MODULE_NAME); }) | ||
|
||
stop: ## Stop the built binary | ||
@echo "Stopping the binary..." | ||
@sudo killall $(MODULE_NAME) 2>/dev/null || true | ||
@echo "Stopped!" | ||
|
||
clean: ## Remove previous build | ||
@echo "Cleaning build..." | ||
@rm -f coverage.out | ||
@rm -f api/docs.go api/swagger.* | ||
@cd cmd/$(MODULE_NAME) && $(GO) clean | ||
@echo "Cleaned!" | ||
|
||
# compose: swag ## Build and up services by docker compose | ||
# @echo "Building and starting services by docker compose..." | ||
# @cd deployments/docker-compose && DOCKER_BUILDKIT=1 docker compose up --build | ||
|
||
# compose-up: ## Up services by docker compose | ||
# @echo "Starting services by docker compose..." | ||
# @cd deployments/docker-compose && docker compose up | ||
|
||
# compose-down: ## Down services by docker compose | ||
# @echo "Removing services by docker compose..." | ||
# @cd deployments/docker-compose && docker compose down | ||
|
||
help: ## Display this help screen | ||
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}' |
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
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
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
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
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.