In the last post, we explored Factor 1: Codebase and how a single source of truth keeps deployments consistent across environments.
Now, let’s move on to Factor 2: Dependencies—one of the most important steps for ensuring your app runs the same way in development, staging, and production.
"Explicitly declare and isolate dependencies." – 12factor.net
Every application relies on third-party packages, libraries, or frameworks to function. Without a clear list of these dependencies, developers risk running into the classic:
"It works on my machine!"
By declaring dependencies explicitly, you:
By isolating dependencies, you:
Most programming languages use a manifest file to declare dependencies:
requirements.txt or pyproject.toml
package.json
pom.xml or build.gradle
Best practice: list every required dependency—including specific versions—to avoid unplanned upgrades or mismatched behavior.
Isolation prevents conflicts between different applications that use the same packages.
Options include:
venv or pipenv
node_modules in each projectIn cloud-native environments, containerization has become the preferred method, offering the highest level of isolation and consistency.
Alibaba Cloud provides a robust set of services to help declare, package, and isolate dependencies effectively:
Here’s a sample workflow using Node.js, Docker, and Alibaba Cloud:
dockerfile
FROM node:20-alpine
WORKDIR /app
COPY package*.json ./
RUN npm ci
COPY . .
CMD ["node", "server.js"]
Process:
package.json with exact versions.This ensures every environment runs with the exact same dependencies, eliminating inconsistencies.
In Factor 3 – Config, we’ll talk about separating configuration from code and how Alibaba Cloud’s Secrets Manager and ConfigMaps make it simple and secure.
This article is based on my own understanding and experience applying the 12 Factor App methodology using Alibaba Cloud services. All Alibaba Cloud service names and features mentioned are publicly available and documented by Alibaba Cloud.
Blog 2: Factor 1 - Codebase: Managing a Single Codebase Across Multiple Deploys with Alibaba Cloud
quetuliokervin - August 6, 2025
Alibaba Clouder - March 12, 2020
Alibaba Clouder - December 15, 2020
Alibaba Cloud Native Community - April 7, 2022
Alex - January 22, 2020
XianYu Tech - May 13, 2021
Alibaba Cloud for Generative AI
Accelerate innovation with generative AI to create new business success
Learn More