refactor: migrate to Podman and enhance Makefile

Replace Docker with Podman and upgrade Makefile with help system and new developer-friendly targets.
This commit is contained in:
Vito Castellano 2025-10-11 01:57:41 +02:00
commit f9faa1f1e2
No known key found for this signature in database
GPG key ID: E13085DB38BC5819
2 changed files with 91 additions and 32 deletions

8
.env
View file

@ -1,10 +1,6 @@
APP_NAME=bbrew
APP_VERSION=0.0.1-local
### Docker
DOCKER_IMAGE_NAME=bbrew
### Build
BUILD_GOVERSION=1.20
CONTAINER_IMAGE_NAME=bbrew
BUILD_GOVERSION=1.25
BUILD_GOOS=darwin
BUILD_GOARCH=arm64

115
Makefile
View file

@ -1,63 +1,126 @@
##############################
# VARIABLES
##############################
ifneq (,$(wildcard ./.env))
include .env
export
endif
%:@
# Load .env if exists (loaded first so defaults can override if not set)
-include .env
# Default values (can be overridden by .env or command line)
APP_NAME ?= bbrew
APP_VERSION ?= 0.0.1-local
CONTAINER_IMAGE_NAME ?= bbrew
BUILD_GOVERSION ?= 1.25
BUILD_GOOS ?= $(shell go env GOOS)
BUILD_GOARCH ?= $(shell go env GOARCH)
# Container runtime command
CONTAINER_RUN = podman run --rm -v $(PWD):/app $(CONTAINER_IMAGE_NAME)
##############################
# HELP
##############################
.PHONY: help
help: ## Show this help message
@echo "Usage: make [target]"
@echo ""
@echo "Available targets:"
@awk 'BEGIN {FS = ":.*?## "} /^[a-zA-Z_-]+:.*?## / {printf " \033[36m%-25s\033[0m %s\n", $$1, $$2}' $(MAKEFILE_LIST) | sort
.DEFAULT_GOAL := help
##############################
# CONTAINER
##############################
.PHONY: container-build-image
container-build-image:
@podman build -f Containerfile -t $(DOCKER_IMAGE_NAME) .
container-build-image: ## Build container image
@podman build -f Containerfile -t $(CONTAINER_IMAGE_NAME) .
.PHONY: container-build-force-recreate
container-build-force-recreate:
@podman build --no-cache -f Containerfile -t $(DOCKER_IMAGE_NAME) .
.PHONY: container-build-force
container-build-force: ## Force rebuild container image (no cache)
@podman build --no-cache -f Containerfile -t $(CONTAINER_IMAGE_NAME) .
.PHONY: container-clean
container-clean: ## Remove container image
@podman rmi $(CONTAINER_IMAGE_NAME) 2>/dev/null || true
##############################
# RELEASE
##############################
.PHONY: release-snapshot
release-snapshot: container-build-image # Builds the project in snapshot mode and releases it [This is used for testing releases]
@podman run --rm -v $(PWD):/app $(DOCKER_IMAGE_NAME) goreleaser release --snapshot --clean
release-snapshot: container-build-image ## Build and release snapshot (testing)
@$(CONTAINER_RUN) goreleaser release --snapshot --clean
.PHONY: build-snapshot # Builds the project in snapshot mode [This is used for testing releases]
build-snapshot: container-build-image
@podman run --rm -v $(PWD):/app $(DOCKER_IMAGE_NAME) goreleaser build --snapshot --clean
.PHONY: build-snapshot
build-snapshot: container-build-image ## Build snapshot without release
@$(CONTAINER_RUN) goreleaser build --snapshot --clean
##############################
# BUILD
##############################
.PHONY: build
build: container-build-image
@podman run --rm -v $(PWD):/app $(DOCKER_IMAGE_NAME) \
env GOOS=$(BUILD_GOOS) GOARCH=$(BUILD_GOARCH) go build -o $(APP_NAME) ./cmd/$(APP_NAME)
build: container-build-image ## Build the application binary
@$(CONTAINER_RUN) env GOOS=$(BUILD_GOOS) GOARCH=$(BUILD_GOARCH) \
go build -o $(APP_NAME) ./cmd/$(APP_NAME)
.PHONY: build-local
build-local: ## Build locally without container (requires Go installed)
@go build -o $(APP_NAME) ./cmd/$(APP_NAME)
.PHONY: run
run: build
./$(APP_NAME)
run: build ## Build and run the application
@./$(APP_NAME)
.PHONY: clean
clean: ## Clean build artifacts
@rm -f $(APP_NAME)
@rm -rf dist/
##############################
# HELPER
# QUALITY
##############################
.PHONY: quality
quality: container-build-image
@podman run --rm -v $(PWD):/app $(DOCKER_IMAGE_NAME) golangci-lint run
quality: container-build-image ## Run linter checks
@$(CONTAINER_RUN) golangci-lint run
.PHONY: quality-local
quality-local: ## Run linter locally (requires golangci-lint installed)
@golangci-lint run
.PHONY: test
test: ## Run tests
@go test -v ./...
.PHONY: test-coverage
test-coverage: ## Run tests with coverage
@go test -v -coverprofile=coverage.out ./...
@go tool cover -html=coverage.out -o coverage.html
##############################
# WEBSITE
##############################
.PHONY: build-site
build-site:
build-site: ## Build the static website
@node build.js
.PHONY: serve-site
serve-site:
serve-site: ## Serve the website locally
@npx http-server docs -p 3000
.PHONY: dev-site
dev-site: build-site serve-site
dev-site: build-site serve-site ## Build and serve the website
##############################
# UTILITY
##############################
.PHONY: install
install: build-local ## Install binary to $GOPATH/bin
@go install ./cmd/$(APP_NAME)
.PHONY: deps
deps: ## Download and tidy dependencies
@go mod download
@go mod tidy
.PHONY: deps-update
deps-update: ## Update all dependencies
@go get -u ./...
@go mod tidy