Skip to content

Build

A build is the process of turning source code and its dependencies into a runnable artifact — a binary, a bundle, a container image, a static site — that can be deployed and executed.

Definition

What it is

A build is a transformation. Input: source code, dependencies, configuration. Output: an artifact that can run somewhere else, without the tooling that produced it. The transformation may be gcc compiling a C file to an executable, webpack bundling JavaScript modules into a single file, docker build producing a container image, php bin/build-all.php generating a static site, or mvn package producing a JAR.

A build is reproducible when running it twice on the same inputs produces bit-identical outputs. Reproducibility is the foundation of trust: without it, "works on my machine" is not a bug, it is a design.

Why it matters

When a build is reproducible, a bug can be traced from the artifact back to the source. When it is not, the same commit produces different binaries on different machines, and no one can tell what code is actually running. A build that is slow makes deployments infrequent; a build that is unreliable makes them anxious; a build that is opaque makes them dangerous. The build is the most-executed piece of infrastructure a team has, and usually the least audited.

Build vs compile vs deploy vs release

Aspect

Compile

Build

Deploy

Release

Input

Source file

Project

Artifact

Deployed code

Output

Object file

Artifact

Running service

User-visible feature

Scope

One file

Whole project

One environment

Users

Common tool

gcc, javac

make, gradle, docker

CI/CD pipeline

Feature flag

The build pipeline

graph LR
  S[Source] --> F[Fetch deps]
  F --> C[Compile]
  C --> T[Test]
  T --> P[Package]
  P --> A[Artifact]
  A --> R[Registry]
  style S fill:#FFF3E0
  style R fill:#E8F5E9

How to build reproducibly

A build you can trust

  1. Pin every dependency

    package-lock.json, composer.lock, go.sum, Gemfile.lock. A dependency on latest is a dependency on tomorrow's bug.

  2. Pin tool versions

    Node 20.10.0, PHP 8.2.15, Go 1.21.5. Not "the latest LTS". The latest LTS changes; your build should not.

  3. Avoid timestamps in output

    A build timestamp in the artifact makes two builds differ even when the source is identical. For build info, use git commit hash.

  4. Cache the deterministic parts

    Dependencies change less often than source. Cache node_modules or vendor between builds to cut build time by 80%.

Common failures

Origin

The word entered English around the 12th century as byldan, "to construct a dwelling" — related to bold (a house) and buan (to dwell). Its meaning extended to any act of construction: a house, a bridge, a reputation. The software sense came with Unix make in 1976, which formalized the "build" step for C programs: a Makefile describes the commands to turn source into binary. From there, "build" became the generic term for any project-level transformation: Java mvn build, JavaScript npm run build, Docker docker build, static sites npm run build.

A build is the output of a build process. It is the artifact that gets deployed. Build reproducibility is the property that the same source, built twice, produces the same artifact.

— The Reproducible Builds project, *Definition*, 2024 (paraphrase)
1976 · make formaliza el build en Unix
2000 · Ant/Maven popularizan builds Java declarativas
2010 · npm/bower/grunt/gulp emergen para JS
2013 · Docker build introduce build como capa inmutable
2018 · Reproducible Builds adquiere tracción seria
2× · factor de mejora típico con cache bien configurado

Evidence

FAQ

Build vs compile?

Compile turns one source file into object code. Build turns the whole project into an artifact. A build includes compiling, but also bundling, testing and packaging.

Why reproducibility?

Because without it, "the code" is not one thing. Two developers with the same commit get two different artifacts, and neither can tell what is running in production.

How to make builds fast?

Cache dependencies, parallelize independent steps, and only rebuild what changed. Most builds spend 80% of their time on 20% of the work.

Is a build a test?

No. A build produces the artifact; tests verify its behaviour. But most build pipelines run tests after building, because a broken build cannot be tested.

Connections

Etymology

Origin: inherited

  • build (verb): Old English byldan, "to construct a dwelling"

Semantic network

Buildoperationssoftware-eDeployContinuousmakeDockerArtifactreproducib

● broader ● narrower ● related

Broader

  • operations
  • software-engineering

Related

Used in the garden

Sources