Skip to content

Makefile Reference

Scansca includes a comprehensive Makefile to simplify development, building, testing, and documentation workflows. This document explains all available make targets and how to use them.

Quick Reference

Category Command Description
Building make build Build the Scansca binary
make clean Remove build artifacts
make all Clean and build
make run Build and run Scansca
Dependencies make deps Download Go dependencies
make tidy Clean up Go module files
Docker make docker Build Docker image
make docker-compose Start services with Docker Compose
make docker-compose-down Stop Docker Compose services
Code Quality make lint Run linters
make fmt Format code
make vet Run Go vet
make test Run tests
Documentation make docs Start documentation server
make docs-stop Stop documentation server

Building and Running

Building the Application

To build the Scansca binary:

1
make build

This creates a binary in the bin/ directory.

Cleaning Build Artifacts

To remove build artifacts:

1
make clean

Building and Running in One Step

To build and immediately run Scansca:

1
make run

Dependency Management

Downloading Dependencies

To download all Go module dependencies:

1
make deps

Tidying Dependencies

To clean up unused dependencies in Go module files:

1
make tidy

Docker Operations

Building a Docker Image

To build a Docker image for Scansca:

1
make docker

Running with Docker Compose

To start Scansca and its dependencies (like PostgreSQL) using Docker Compose:

1
make docker-compose

Stopping Docker Compose Services

To stop all services started with Docker Compose:

1
make docker-compose-down

Code Quality

Running Linters

To run code linters:

1
make lint

Formatting Code

To automatically format Go code:

1
make fmt

Vetting Code

To run Go's static analysis tool:

1
make vet

Running Tests

To run all tests:

1
make test

Documentation

Starting the Documentation Server

To build and start the documentation server:

1
make docs

By default, this serves documentation at http://localhost:8090. You can change the port by setting the DOCS_PORT environment variable:

1
DOCS_PORT=8888 make docs

Stopping the Documentation Server

To stop the running documentation server:

1
make docs-stop

Environment Variables

The Makefile supports several environment variables:

Variable Default Description
VERSION Git describe output or "dev" Sets the version string in the binary
DOCS_PORT 8090 The port for the documentation server

Extending the Makefile

To add new targets to the Makefile, follow these guidelines:

  1. Add the target name to the .PHONY list
  2. Place the target in the appropriate section
  3. Add comments to explain what the target does
  4. Follow the established pattern for echo commands

Example of adding a new target:

1
2
3
4
# In the appropriate section
new-target:
    @echo "Doing something new..."
    @command-to-run