Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add C++ profile to Docker Compose and Updatecli #377

Open
wants to merge 219 commits into
base: main
Choose a base branch
from

Conversation

gounthar
Copy link
Owner

@gounthar gounthar commented Feb 21, 2025

Fixes #376

Add a new profile in the Docker Compose file for building C++ source code with Jenkins.

  • Docker Compose Files:
    • Add a cpp profile in docker-compose.yaml and build-docker-compose.yaml.
    • Include necessary service definitions, dependencies, healthcheck, and volume configurations.
  • Dockerfile:
    • Create dockerfiles/cpp/Dockerfile with necessary C++ build tools including build-essential, cmake, gcc, g++, clang, make, libstdc++-dev, and pkg-config.
    • Set environment variables and ensure ownership of the Jenkins agent home directory.
  • Updatecli Manifest:
    • Add updatecli/updatecli.d/cpp.yaml for managing the C++ Dockerfile.
    • Ensure the manifest includes the necessary dependencies for the C++ build environment.
  • GitHub Actions:
    • Modify .github/workflows/github-docker-registry-push.yml to add a new job for building and pushing the C++ Docker image to ghcr.

For more details, open the Copilot Workspace session.

Summary by CodeRabbit

  • New Features
    • Introduced a new Jenkins agent service tailored for C++ tutorial workflows, expanding the CI/CD pipeline with automated, multi-platform Docker image builds.
    • Added a dedicated container service featuring robust health checks and clear dependency management to ensure reliable performance.
    • Enhanced the build environment with essential C++ development tools, streamlining image updates and improving overall agent efficiency.
    • Implemented a new target for updating the Docker image tag in the C++ Dockerfile, enhancing configuration management.

dependabot bot and others added 30 commits January 15, 2024 12:10
Bumps debian from bookworm-20231218 to bookworm-20240110.

---
updated-dependencies:
- dependency-name: debian
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <[email protected]>
…dekick/debian-bookworm-20240110

chore(deps): bump debian from bookworm-20231218 to bookworm-20240110 in /dockerfiles/sidekick
Bumps [updatecli/updatecli-action](https://github.com/updatecli/updatecli-action) from 2.52.0 to 2.53.0.
- [Release notes](https://github.com/updatecli/updatecli-action/releases)
- [Commits](updatecli/updatecli-action@v2.52.0...v2.53.0)

---
updated-dependencies:
- dependency-name: updatecli/updatecli-action
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <[email protected]>
Bumps [anchore/scan-action](https://github.com/anchore/scan-action) from 3.5.0 to 3.6.0.
- [Release notes](https://github.com/anchore/scan-action/releases)
- [Changelog](https://github.com/anchore/scan-action/blob/main/CHANGELOG.md)
- [Commits](anchore/scan-action@1d59d90...0550541)

---
updated-dependencies:
- dependency-name: anchore/scan-action
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <[email protected]>
…cli/updatecli-action-2.53.0

chore(deps): bump updatecli/updatecli-action from 2.52.0 to 2.53.0
…e/scan-action-3.6.0

chore(deps): bump anchore/scan-action from 3.5.0 to 3.6.0
Bumps [updatecli/updatecli-action](https://github.com/updatecli/updatecli-action) from 2.53.0 to 2.54.0.
- [Release notes](https://github.com/updatecli/updatecli-action/releases)
- [Commits](updatecli/updatecli-action@v2.53.0...v2.54.0)

---
updated-dependencies:
- dependency-name: updatecli/updatecli-action
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <[email protected]>
Bumps debian from bookworm-20240110 to bookworm-20240130.

---
updated-dependencies:
- dependency-name: debian
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <[email protected]>
Bumps jenkins/ssh-agent from 5.22.0 to 5.24.0.

---
updated-dependencies:
- dependency-name: jenkins/ssh-agent
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <[email protected]>
Bumps jenkins/ssh-agent from 5.22.0 to 5.24.0.

---
updated-dependencies:
- dependency-name: jenkins/ssh-agent
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <[email protected]>
Bumps jenkins/ssh-agent from 5.22.0 to 5.24.0.

---
updated-dependencies:
- dependency-name: jenkins/ssh-agent
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <[email protected]>
Bumps [release-drafter/release-drafter](https://github.com/release-drafter/release-drafter) from 5 to 6.
- [Release notes](https://github.com/release-drafter/release-drafter/releases)
- [Commits](release-drafter/release-drafter@v5...v6)

---
updated-dependencies:
- dependency-name: release-drafter/release-drafter
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <[email protected]>
Bumps [anchore/scan-action](https://github.com/anchore/scan-action) from 3.6.0 to 3.6.4.
- [Release notes](https://github.com/anchore/scan-action/releases)
- [Changelog](https://github.com/anchore/scan-action/blob/main/CHANGELOG.md)
- [Commits](anchore/scan-action@0550541...3343887)

---
updated-dependencies:
- dependency-name: anchore/scan-action
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <[email protected]>
Bumps jenkins/ssh-agent from 5.22.0 to 5.24.0.

---
updated-dependencies:
- dependency-name: jenkins/ssh-agent
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <[email protected]>
Bumps jenkins/ssh-agent from 5.22.0 to 5.24.0.

---
updated-dependencies:
- dependency-name: jenkins/ssh-agent
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <[email protected]>
Bumps [codacy/codacy-analysis-cli-action](https://github.com/codacy/codacy-analysis-cli-action) from 4.3.0 to 4.4.0.
- [Release notes](https://github.com/codacy/codacy-analysis-cli-action/releases)
- [Commits](codacy/codacy-analysis-cli-action@5cc54a7...33d4559)

---
updated-dependencies:
- dependency-name: codacy/codacy-analysis-cli-action
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <[email protected]>
…cli/updatecli-action-2.54.0

chore(deps): bump updatecli/updatecli-action from 2.53.0 to 2.54.0
…dekick/debian-bookworm-20240130

chore(deps): bump debian from bookworm-20240110 to bookworm-20240130 in /dockerfiles/sidekick
…thon/jenkins/ssh-agent-5.24.0

chore(deps): bump jenkins/ssh-agent from 5.22.0 to 5.24.0 in /dockerfiles/python
…ven/jenkins/ssh-agent-5.24.0

chore(deps): bump jenkins/ssh-agent from 5.22.0 to 5.24.0 in /dockerfiles/maven
…e-drafter/release-drafter-6

chore(deps): bump release-drafter/release-drafter from 5 to 6
…e/scan-action-3.6.4

chore(deps): bump anchore/scan-action from 3.6.0 to 3.6.4
…lti/jenkins/ssh-agent-5.24.0

chore(deps): bump jenkins/ssh-agent from 5.22.0 to 5.24.0 in /dockerfiles/multi
Fixes #376

Add a new profile in the Docker Compose file for building C++ source code with Jenkins.

* **Docker Compose Files:**
  * Add a `cpp` profile in `docker-compose.yaml` and `build-docker-compose.yaml`.
  * Include necessary service definitions, dependencies, healthcheck, and volume configurations.
* **Dockerfile:**
  * Create `dockerfiles/cpp/Dockerfile` with necessary C++ build tools including `build-essential`, `cmake`, `gcc`, `g++`, `clang`, `make`, `libstdc++-dev`, and `pkg-config`.
  * Set environment variables and ensure ownership of the Jenkins agent home directory.
* **Updatecli Manifest:**
  * Add `updatecli/updatecli.d/cpp.yaml` for managing the C++ Dockerfile.
  * Ensure the manifest includes the necessary dependencies for the C++ build environment.
* **GitHub Actions:**
  * Modify `.github/workflows/github-docker-registry-push.yml` to add a new job for building and pushing the C++ Docker image to ghcr.

---

For more details, open the [Copilot Workspace session](https://copilot-workspace.githubnext.com/gounthar/quickstart-tutorials/issues/376?shareId=XXXX-XXXX-XXXX-XXXX).
Copy link

coderabbitai bot commented Feb 21, 2025

Walkthrough

This pull request introduces a new Jenkins C++ agent by extending the CI/CD pipeline. A GitHub Actions workflow now conditionally builds and pushes a Docker image for the C++ tutorial. Additionally, two Docker Compose files gain a new service configuration for the C++ agent, a Dockerfile is added for building the C++ environment, and an updatecli target updates the Docker image tag.

Changes

File(s) Change Summary
.github/workflows/github-docker-registry-push.yml Added a new job step that conditionally builds and pushes the Jenkins C++ agent Docker image using docker/build-push-action@v6, triggered if the C++ Dockerfile is modified.
build-docker-compose.yaml, docker-compose.yaml Introduced a new cpp service: one file uses a build context (dockerfiles/cpp/.), the other references an image variable. Both define container name, profile, dependencies on sidekick_service and jenkins_controller, include similar health checks and volume mounts.
dockerfiles/cpp/Dockerfile Created a new Dockerfile for a C++ build environment based on jenkins/ssh-agent:6.9.0, which installs necessary C++ tools, updates the PATH, and sets proper permissions for the Jenkins agent home directory.
updatecli/updatecli.d/ssh-agent.yaml Added a new updatecli target jenkins/cpp-agent that modifies the FROM statement in the C++ Dockerfile to bump the Docker image tag, ensuring consistency with the updated C++ agent image.

Sequence Diagram(s)

sequenceDiagram
    participant Dev as Developer
    participant GH as GitHub Repository
    participant GA as GitHub Actions Workflow
    participant DBA as Docker Build & Push Action
    participant GCR as GitHub Container Registry

    Dev->>GH: Push code changes
    GH->>GA: Trigger workflow
    GA->>GA: Check if `dockerfiles/cpp/Dockerfile` is modified
    alt Dockerfile modified
        GA->>DBA: Build image for C++ agent (linux/amd64, linux/aarch64)
        DBA->>GCR: Push built image with tag format
    else Dockerfile not modified
        GA-->>GA: Skip C++ build step
    end
Loading
sequenceDiagram
    participant DC as Docker Compose
    participant SS as sidekick_service
    participant JC as jenkins_controller
    participant CPP as cpp Service
    participant HC as Healthcheck

    DC->>SS: Start sidekick_service
    SS-->>DC: Service completed successfully
    DC->>JC: Start jenkins_controller
    JC-->>DC: Service started
    DC->>CPP: Initiate cpp service with volume mount
    CPP->>HC: Run healthcheck every 5s
    HC-->>CPP: Validate `/home/jenkins/.ssh/authorized_keys`
Loading

Poem

I’m a hopping rabbit with a coder’s glee,
Leaping through Docker and CI with ease.
A new C++ agent sprouts like a carrot so bright,
GitHub Actions and Compose dancing in the light.
With each build and push, my heart sings anew—
A joyful code hop from me to you!
🥕🐇


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between ebb061c and 9516933.

📒 Files selected for processing (2)
  • .github/workflows/github-docker-registry-push.yml (1 hunks)
  • docker-compose.yaml (13 hunks)
🚧 Files skipped from review as they are similar to previous changes (2)
  • .github/workflows/github-docker-registry-push.yml
  • docker-compose.yaml

Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR. (Beta)
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@github-actions github-actions bot added the repo label Feb 21, 2025
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

🧹 Nitpick comments (1)
updatecli/updatecli.d/cpp.yaml (1)

1-43: Updatecli Manifest for C++ Build Environment

The Updatecli manifest is well structured. It correctly defines a GitHub SCM block with dynamic placeholders and sets up a shell source that returns the required list of packages. The target configuration properly identifies the Dockerfile (dockerfiles/cpp/Dockerfile) and the apt-get install instruction to update. The action to create a pull request is clearly laid out.

One suggestion: Ensure that the package list echoed in the source exactly matches the apt-get command in the Dockerfile so that dependency updates remain consistent.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 15cfa65 and 3bf124b.

📒 Files selected for processing (5)
  • .github/workflows/github-docker-registry-push.yml (1 hunks)
  • build-docker-compose.yaml (1 hunks)
  • docker-compose.yaml (1 hunks)
  • dockerfiles/cpp/Dockerfile (1 hunks)
  • updatecli/updatecli.d/cpp.yaml (1 hunks)
🧰 Additional context used
🪛 GitHub Actions: Anchore Grype vulnerability scan
dockerfiles/cpp/Dockerfile

[error] 31-31: Plugin prerequisite not met: Plugin configuration-as-code:1932.v75cb_b_f1b_698d (via prism-api:1.29.0-19) depends on plugin-util-api:6.0.0, but there is an older version defined on the top level - plugin-util-api:5.1.0.

⏰ Context from checks skipped due to timeout of 90000ms (2)
  • GitHub Check: Codacy Static Code Analysis
  • GitHub Check: Codacy Security Scan
🔇 Additional comments (4)
dockerfiles/cpp/Dockerfile (1)

1-20: Review of the new C++ Dockerfile

The Dockerfile is clear and straightforward. It builds on the jenkins/ssh-agent:6.9.0 base image and installs all the necessary C++ build tools using apt-get install -y --no-install-recommends. The cleanup command (rm -rf /var/lib/apt/lists/*) helps reduce the image size. Setting the PATH environment variable and adjusting ownership of the Jenkins agent home directory are implemented correctly.

However, note the pipeline failure message regarding a plugin prerequisite (plugin-util-api version mismatch). While this message does not directly impact the Dockerfile’s instructions, please verify the top-level plugin versions in your Jenkins configuration to ensure all dependencies (e.g., plugin-util-api) meet the required versions.

build-docker-compose.yaml (1)

208-224: New C++ Service in Build Docker Compose

The addition of the cpp service is implemented consistently with the other agent services. The build context (dockerfiles/cpp/.), container naming (desktop-jenkins_agent-1-cpp), and profile configuration (cpp) follow the established patterns. The dependencies on sidekick_service and jenkins_controller, along with the healthcheck (ensuring /home/jenkins/.ssh/authorized_keys exists), are set correctly. This integration should provide a robust C++ build environment for your CI/CD chain.

Please verify during integration testing that this service interacts correctly with the rest of the services.

.github/workflows/github-docker-registry-push.yml (1)

208-217: GitHub Actions Job for C++ Jenkins Agent

The new job step “Build and push the jenkins agent for cpp tutorial” is added appropriately. The conditional check using if: contains(env.files, 'dockerfiles/cpp/Dockerfile') ensures that the step runs only when the C++ Dockerfile has been modified. The build context (./dockerfiles/cpp), platform specifications (linux/amd64, linux/aarch64), and tagging format with ${{ env.BRANCH }} are consistent with your other job steps.

Everything appears to be correctly configured.

docker-compose.yaml (1)

284-300: Configuration of the C++ Service in Docker Compose

The newly added cpp service in docker-compose.yaml mirrors the configuration found in build-docker-compose.yaml. It uses environment variables to determine the Docker image, sets the container name to desktop-jenkins_agent-1-cpp, and associates the service with the cpp profile. Dependencies on both sidekick_service and jenkins_controller are appropriately declared, and the healthcheck confirms the presence of the /home/jenkins/.ssh/authorized_keys file. The volume mapping for agent-ssh-dir as read-only is consistent with other agent services.

The configuration is well integrated and consistent with the overall setup.

FROM jenkins/ssh-agent:6.9.0

# Install necessary C++ build tools
RUN apt-get update && apt-get install -y --no-install-recommends \

Check notice

Code scanning / Hadolint (reported by Codacy)

Pin versions in apt get install. Instead of apt-get install <package> use apt-get install <package>=<version> Note

Pin versions in apt get install. Instead of apt-get install <package> use apt-get install <package>=<version>
# Check if the service has dependencies
if yq e ".services.${service}.depends_on" "$original_file" -e > /dev/null; then
# Read dependencies of the service
local dependencies=($(yq e ".services.${service}.depends_on | keys" "$original_file" -o json | jq -r '.[]'))

Check notice

Code scanning / Shellcheck (reported by Codacy)

Prefer mapfile or read -a to split command output (or quote to avoid splitting). Note

Prefer mapfile or read -a to split command output (or quote to avoid splitting).
declare -A all_dependencies
services=$(yq e '.services | keys' "$original_file" -o json | jq -r '.[]')
for service in $services; do
dependencies=$(yq e ".services.$service.depends_on | keys" "$original_file" -o json | jq -r '.[]')

Check notice

Code scanning / Shellcheck (reported by Codacy)

Variable was used as an array but is now assigned a string. Note

Variable was used as an array but is now assigned a string.
services=$(yq e '.services | keys' "$original_file" -o json | jq -r '.[]')
for service in $services; do
dependencies=$(yq e ".services.$service.depends_on | keys" "$original_file" -o json | jq -r '.[]')
for dependency in $dependencies; do

Check notice

Code scanning / Shellcheck (reported by Codacy)

Expanding an array without an index only gives the first element. Note

Expanding an array without an index only gives the first element.
for service in $services; do
dependencies=$(yq e ".services.$service.depends_on | keys" "$original_file" -o json | jq -r '.[]')
for dependency in $dependencies; do
all_dependencies["$dependency"]=1

Check notice

Code scanning / Shellcheck (reported by Codacy)

all_dependencies appears unused. Verify use (or export if used externally). Note

all_dependencies appears unused. Verify use (or export if used externally).

# Generate the docker-compose file for the profile
echo "Generating docker-compose-$profile.yaml"
yq e ".services | with_entries(select(.key as \$k | .key == \"$included_services_list\"))" "$original_file" > "docker-compose-$profile.yaml"

Check notice

Code scanning / Shellcheck (reported by Codacy)

included_services_list is referenced but not assigned. Note

included_services_list is referenced but not assigned.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Create a New Profile in the Docker Compose File, an Associated Dockerfile, and an Updatecli Manifest
2 participants