liveBook · Manning

Dependency

As explained in Road to Kubernetes

An application dependency is an external library, service, runtime, or other component required by an application.

An application dependency is an external library, service, runtime, operating-system component, hardware capability, or other requirement needed to build, compile, or run software. Dependencies explain why an application that works on one device may fail on another. section 1.3

Common dependency categories include:

  • Operating-system dependencies, such as the platform required by a game or tools installed inside a container. section 1.3 section 5.3.2
  • Runtime and version dependencies, such as Python for FastAPI, Python 3.8 or higher, or Node.js 16.14 or higher. section 1.3 section 3.4
  • Third-party project dependencies, tracked with Python requirements.txt or JavaScript package.json for repeatable environments. section 2.5
  • Hardware dependencies, such as a GPU, network connection, router, CPU, or RAM required by a workload. section 1.3

Managing dependencies becomes harder as software gains packages, runtimes, and system requirements. Virtual environments, version managers, and package manifests isolate projects and make installation more consistent. Containers extend this approach by bundling application code with third-party system-level dependencies into a portable container image. section 3.4 section 5.0

A dependency-aware Python container

A Python Dockerfile can install OS-level packages such as python3-venv, python3-dev, and python3-pip; create a virtual environment; upgrade pip; install requirements.txt; and run the application. Building and running the image tests whether the declared dependency setup produces a usable application. section 5.3.2

Listing 5.6 Python Dockerfile for browsing
# get our Python image
FROM python:3.11.4

# create and move to the /app directory
# all commands after will execute in this directory
WORKDIR /app

# copy our local src folder to /app in the container
COPY ./src/ /app

# Run os-level updates
RUN apt-get update && \
    apt-get install -y python3-venv python3-dev python3-pip

# Create our Python virtual environment
RUN python3 -m venv /opt/venv

# Update the virtual environment pip
RUN /opt/venv/bin/python -m pip install --upgrade pip

# Install our project dependencies
# src/requirements.txt is our local version
RUN /opt/venv/bin/python -m pip install -r requirements.txt

# Run a server to expose copied files
CMD ["/opt/venv/bin/python", "-m", "http.server", "8080"]

Inspect the complete Python Dockerfile to see working-directory setup, source copying, OS-level installation, virtual-environment creation, project-package installation, and application startup. section 5.3.2

How Road to Kubernetes covers it

How deep it goes
Defines dependency categories and demonstrates installation, tracking, and container packaging, while deferring intricate Dockerfile complexity.
Examples
Uses FastAPI, MoviePy, Python requirements.txt, Node.js package.json, virtual environments, and a Python Dockerfile as concrete dependency examples.
What it assumes
Assumes beginner programming knowledge while teaching dependency discovery, runtime version checks, package tracking, and environment isolation.
What you can do after
Operate/configure repeatable Python and Node.js environments, then package their system and project dependencies into Docker images.
How it connects
Connects dependencies with Python, JavaScript, virtual environments, package managers, Docker, container images, CI/CD, and Kubernetes.

Also explained in

Compare how 27 books explain dependency →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Road to Kubernetes. The section links point to the parts of the book it draws on.