Build
Build
The process of converting source code into an executable form. Includes compiling and packaging.
Build
The process of converting source code into an executable form. Includes compiling and packaging.
A Build is the process of converting source code into executable software artifacts. It includes several stages such as compilation, linking, dependency resolution, test execution, and packaging, and is the core of automation in modern software development.
The build process differs by language and platform. Java compiles and then packages into JAR/WAR, JavaScript does bundling and transpiling, Go produces static binaries, and Python creates wheel packages. In container environments, the Docker image is the final artifact.
Build tools handle dependency management and build automation. There are language-specific tools such as Maven/Gradle (Java), npm/yarn (JavaScript), pip/poetry (Python), and cargo (Rust), as well as general-purpose tools such as Bazel and Make.
In practice, the build is the starting point of the CI/CD pipeline. It builds and tests automatically on every code push, and on success pushes the artifact to a repository. Build time optimization, caching, and parallel builds directly affect developer productivity.
# Dockerfile - λ©ν°μ€ν
μ΄μ§ λΉλ μμ
# 1λ¨κ³: λΉλ νκ²½
FROM node:20-alpine AS builder
WORKDIR /app
COPY package*.json ./
# μμ‘΄μ± μ€μΉ (μΊμ νμ©μ μν΄ λ³λ λ μ΄μ΄)
RUN npm ci --only=production
COPY . .
RUN npm run build
# 2λ¨κ³: νλ‘λμ
νκ²½ (μ΅μ μ΄λ―Έμ§)
FROM node:20-alpine AS production
# 보μ: λΉλ£¨νΈ μ¬μ©μ
RUN addgroup -g 1001 -S nodejs && \
adduser -S nextjs -u 1001
WORKDIR /app
# λΉλ μν°ν©νΈλ§ 볡μ¬
COPY --from=builder /app/dist ./dist
COPY --from=builder /app/node_modules ./node_modules
COPY --from=builder /app/package.json ./
USER nextjs
EXPOSE 3000
HEALTHCHECK --interval=30s --timeout=3s \
CMD wget --no-verbose --tries=1 --spider http://localhost:3000/health || exit 1
CMD ["node", "dist/server.js"]
Senior: "The build takes 8 minutes, which is too long to wait on every PR. Let's apply parallel builds and caching to get it under 3 minutes."
Junior: "The Docker layer cache keeps getting invalidated, it seems."
Senior: "It's probably a COPY order issue. Copy things that change less often first, and copy package.json separately so you can use the npm install cache."
Interviewer: "What are the advantages of a Docker multi-stage build?"
Candidate: "You can separate the build environment from the runtime environment. The tools needed for building are not included in the final image, so the image size gets smaller and the attack surface shrinks, which is a security benefit."
Take a mock interview on this topic β WIA SOOM AI Interview Β· Start for free
Reviewer: "If you use npm ci instead of npm install, it installs based on the lock file, which makes the build more deterministic."
Developer: "Right, npm ci is more suitable in a CI environment. I'll separate it from the Dockerfile for local development."