الفلاتر
طريقة البحث
  • الكلمات العادية تجد الأسماء والنصوص والأمثلة.
  • "كلمتان" تجد العبارة بالضبط.
  • --name أو -x تجد خيارًا.
  • #كلمة تبحث داخل الأوامر فقط.
  • @grep تجد الدروس والمعامل التي تستخدم grep.
  • الفلاتر: cat:network · in:labs · level:rhcsa · ch:8 · root:yes. ضع ! قبل كلمة لاستبعادها. OR بين الكلمات تعني إحداها.
  • ↑ ↓ للتنقل · Enter للفتح · Esc للإغلاق · / للبحث

الفصل 2الاسم في الدورة: Build and packages

Build code with make, npm, pip, Maven and Go

Before an app can run in a container, it must be built: packages installed, code compiled, tests run. A DevOps engineer does not need to write the app, but must build it the same way on every laptop and in every pipeline. These 5 tools cover most projects.

  • 6 الدروس
  • 7 الأوامر

هذا الجزء لم يُترجم بعد. أنت ترى النص الإنجليزي.

$ مستخدم عادي# بصلاحية root (أو مع sudo)

المهارات في هذا الفصل

  • أدوات البناء ومديرو الحزم — 5 أدوات

2.1

make — one task runner for every project

make gives every project the same short commands: make build, make test, make deploy.

  • Used for: a task runner around docker, go, npm or terraform; the same steps locally and in CI.
make help
make build TAG=v1.4.0
make -n deploy
make -C services/api test

Good practice:

  • Mark task targets .PHONY; recipe lines start with a Tab.
  • Keep long logic in scripts; the Makefile only calls them.
  • CI runs the same targets as developers (make lint test).

الأوامر في هذا الدرس

2.2

npm — Node.js packages and scripts

npm installs the dependencies of a JavaScript project and runs its scripts.

  • Used for: frontends and Node.js services; npm ci in Dockerfiles and pipelines.
npm ci
npm test
npm run build
npm audit --audit-level=high

Good practice:

  • Commit package-lock.json; use npm ci, not npm install, in CI.
  • --omit=dev in production images; cache ~/.npm in CI.

الأوامر في هذا الدرس

2.3

pip — Python packages

pip installs Python packages, best inside a virtual environment.

  • Used for: Python services, scripts, and tools like Ansible.
python3 -m venv .venv && source .venv/bin/activate
pip install -r requirements.txt
pip freeze > requirements.txt
pip install --no-cache-dir -r requirements.txt

Good practice:

  • Never sudo pip install on the system Python.
  • Pin versions (==) or use a lock file with hashes.

2.4

Maven — Java builds

mvn builds, tests and packages Java apps from pom.xml and pushes the JAR to an artifact repository.

  • Used for: company Java services in Jenkins and GitLab pipelines.
mvn -B clean verify
mvn -B -DskipTests package
mvn -B -s ci-settings.xml deploy
mvn dependency:tree

Good practice:

  • -B -ntp for short CI logs; cache ~/.m2/repository.
  • Credentials in settings.xml from CI secrets, never in pom.xml.

الأوامر في هذا الدرس

2.5

Go — the language of cloud-native tools

go builds one static binary — perfect for tiny container images and internal tools.

  • Used for: CLIs, exporters, Kubernetes operators; reading the code of Docker, Kubernetes and Terraform.
go mod tidy
go test -race ./...
CGO_ENABLED=0 go build -trimpath -ldflags "-s -w" -o bin/app .
GOOS=linux GOARCH=arm64 go build -o bin/app-arm64 .

Good practice:

  • Commit go.mod and go.sum; run go vet and govulncheck in CI.
  • Build static binaries and use a distroless or scratch base image.

الأوامر في هذا الدرس

2.6

Use the same build in every place

"It works on my machine" ends when the build runs in a container with pinned versions.

  1. Pin the tool versions (Node 22, Go 1.23, Java 21) in the Dockerfile or CI file.
  2. Use the lock file of the language (package-lock.json, go.sum, requirements.txt with ==).
  3. Build in a multi-stage Dockerfile: big build image, small run image.
  4. Cache the package folders in CI (~/.npm, ~/.m2, ~/go/pkg/mod).
  5. Push the result to an artifact or image registry, never rebuild the same version twice.

تذكّر

Build once, deploy the same artifact to dev, staging and production.

كل الأوامر في هذا الفصل