Why Justfile Outshines Makefile in Modern DevOps Workflows”

suyog shinde
3 min readJan 23, 2025

--

DevOps engineers often juggle multiple tasks — container orchestration, CI/CD pipelines, cloud deployments, and more. Automation tools like Makefile have been around for decades, but modern alternatives such as Justfile offer fresh, user-friendly approaches to command automation. In this blog, we’ll explore how Justfile can ease a DevOps engineer’s life, with complex, real-world examples to demonstrate its advantages.

What is a Makefile?

Makefile was originally designed to manage the compilation of programs, particularly in C/C++. Over time, it became a go-to for task automation, handling anything from Docker builds to running tests.

Strengths of Makefile:

  • Dependency Management: Useful for building projects with complex dependency trees.
  • Wide Adoption: Comes pre-installed on most systems.

Challenges for DevOps Engineers:

  • Verbosity: Complex tasks require verbose, often unreadable code.
  • Error-Prone Syntax: Requires tabs for indentation, leading to debugging nightmares.
  • Limited Modern Features: Lacks support for scoped variables and advanced string interpolation.

Introducing Justfile

Justfile is a modern command runner with a simpler, more intuitive syntax. Designed to streamline workflows, it focuses on usability and flexibility.

Why Justfile is a Game-Changer:

  • Readable Syntax: No tab-induced errors.
  • Powerful Features: Includes scoped variables, string interpolation, and conditionals.
  • Portability: A single binary that works across platforms.

Let’s compare Makefile and Justfile for a common task: starting a Docker container.

Makefile:

start:
docker-compose up -d

Justfile:

start:
docker-compose up -d

Key Difference: Justfile eliminates the need for tabs, making it less error-prone and easier to read.

Advanced Use Cases

Let’s explore scenarios where Justfile simplifies complex DevOps workflows.

1. Dynamic Task Execution with Parameters

Imagine deploying to different environments (e.g., dev, staging, production).

Justfile:

deploy(env):
echo "Deploying to environment: {{env}}"
kubectl apply -f deployment-{{env}}.yaml

Makefile:

deploy:
@if [ -z "$(env)" ]; then \
echo "Environment not specified"; \
exit 1; \
fi
kubectl apply -f deployment-$(env).yaml

Why Justfile Wins:

  • Built-in support for parameters.
  • Cleaner, more concise syntax.

2. Multi-Step CI/CD Pipelines

DevOps pipelines often involve chained tasks like testing, building, and deploying.

Justfile:

test:
echo "Running tests..."
pytest tests/
build:
echo "Building the project..."
docker build -t my-app .
deploy:
echo "Deploying application..."
kubectl apply -f deployment.yaml
pipeline: test build deploy

Makefile:

test:
echo "Running tests..."
pytest tests/
build:
echo "Building the project..."
docker build -t my-app .
deploy:
echo "Deploying application..."
kubectl apply -f deployment.yaml
pipeline: test build deploy
$(MAKE) test
$(MAKE) build
$(MAKE) deploy

Why Justfile Wins:

  • Simplified task chaining without manual invocation.

3. Parallel Task Execution

Parallelism is crucial for speeding up pipelines.

Justfile:

clean-up:
docker-compose down
echo "Containers stopped."
clear-cache:
rm -rf /tmp/cache
echo "Cache cleared."
reset: clean-up & clear-cache

Makefile:

clean-up:
docker-compose down
@echo "Containers stopped."
clear-cache:
rm -rf /tmp/cache
@echo "Cache cleared."
reset:
$(MAKE) -j clean-up clear-cache

Why Justfile Wins:

  • Intuitive parallel execution with &.
  • No extra configuration needed.

4. Conditional Logic

Conditional logic is often needed for complex deployments.

Justfile:

deploy(env):
@if [ "{{env}}" == "prod" ]; then
echo "Deploying to production...";
kubectl apply -f prod-deployment.yaml;
else
echo "Deploying to {{env}} environment...";
kubectl apply -f dev-deployment.yaml;
fi

Makefile:

deploy:
@if [ "$(env)" == "prod" ]; then \
echo "Deploying to production..."; \
kubectl apply -f prod-deployment.yaml; \
else \
echo "Deploying to $(env) environment..."; \
kubectl apply -f dev-deployment.yaml; \
fi

Why Justfile Wins:

  • Inline conditionals are more readable and maintainable.

Conclusion

Both Makefile and Justfile are powerful tools, but Justfile’s simplicity and modern features make it a better fit for DevOps workflows. By reducing verbosity, improving readability, and offering advanced features, Justfile empowers engineers to focus on solving problems instead of debugging automation scripts.

--

--

No responses yet