Docs / Automation & IaC / How to Use Make and Makefiles for Build Automation

How to Use Make and Makefiles for Build Automation

By Admin · Mar 1, 2026 · Updated Apr 23, 2026 · 27 views · 2 min read

How to Use Make and Makefiles for Build Automation

Make is a classic build automation tool available on virtually every Linux system, including your Breeze server. Makefiles define targets and their dependencies, making complex build and deployment tasks repeatable.

Installing Make

sudo apt install -y make    # Debian/Ubuntu
sudo dnf install -y make    # RHEL/Fedora

Basic Makefile Structure

Create a Makefile in your project root:

.PHONY: build test deploy clean

APP_NAME := myapp
VERSION := $(shell git describe --tags --always)

build:
	@echo "Building $(APP_NAME) $(VERSION)..."
	docker build -t $(APP_NAME):$(VERSION) .

test:
	@echo "Running tests..."
	docker run --rm $(APP_NAME):$(VERSION) npm test

deploy: build test
	@echo "Deploying to production..."
	docker tag $(APP_NAME):$(VERSION) $(APP_NAME):latest
	docker compose up -d

clean:
	docker rmi $(APP_NAME):$(VERSION) || true
	docker system prune -f

Running Targets

make build       # Build only
make test        # Run tests
make deploy      # Build, test, then deploy
make clean       # Clean up

Advanced Features

  • Variables — define reusable values with VAR := value
  • Dependenciesdeploy: build test ensures build and test run first
  • Phony targets.PHONY prevents conflicts with files of the same name
  • Shell commands — prefix with @ to suppress echoing
  • Conditionals — use ifeq/ifdef for environment-specific logic

Makefiles are an excellent lightweight alternative to heavier CI/CD tools for automating routine tasks on your Breeze server.

Was this article helpful?