bazel updates / dockerfile cleanup for flowger #2289

Merged
mfreeman451 merged 1 commit from refs/pull/2289/head into main 2025-10-06 02:42:50 +00:00
mfreeman451 commented 2025-10-06 02:13:08 +00:00 (Migrated from github.com)
Owner

Imported from GitHub pull request.

Original GitHub pull request: #1718
Original author: @mfreeman451
Original URL: https://github.com/carverauto/serviceradar/pull/1718
Original created: 2025-10-06T02:13:08Z
Original updated: 2025-10-06T02:42:53Z
Original head: carverauto/serviceradar:chore/bazel_flowgger_build_fix
Original base: main
Original merged: 2025-10-06T02:42:50Z by @mfreeman451

PR Type

Enhancement


Description

  • Replace default features with explicit feature flags

  • Improve Docker build caching and dependency management

  • Add locked dependency resolution for reproducible builds


Diagram Walkthrough

flowchart LR
  A["Bazel BUILD.bazel"] --> B["Replace default features"]
  B --> C["Add explicit feature flags"]
  D["Dockerfile"] --> E["Improve dependency caching"]
  E --> F["Add locked builds"]

File Walkthrough

Relevant files
Configuration changes
BUILD.bazel
Replace default features with explicit flags                         

cmd/flowgger/BUILD.bazel

  • Replace "default" feature with explicit feature flags
  • Add gelf, passthrough, rfc3164, rfc5424, syslog, tls features
  • Apply changes to both rust_library and rust_binary targets
+12/-2   
Dockerfile
Improve Docker build caching and reproducibility                 

cmd/flowgger/Dockerfile

  • Copy actual workspace contents instead of stub files
  • Add Cargo.lock and build.rs to dependency layer
  • Use --locked flag for reproducible builds
  • Specify explicit features matching Bazel configuration
+12/-17 

Imported from GitHub pull request. Original GitHub pull request: #1718 Original author: @mfreeman451 Original URL: https://github.com/carverauto/serviceradar/pull/1718 Original created: 2025-10-06T02:13:08Z Original updated: 2025-10-06T02:42:53Z Original head: carverauto/serviceradar:chore/bazel_flowgger_build_fix Original base: main Original merged: 2025-10-06T02:42:50Z by @mfreeman451 --- ### **PR Type** Enhancement ___ ### **Description** - Replace default features with explicit feature flags - Improve Docker build caching and dependency management - Add locked dependency resolution for reproducible builds ___ ### Diagram Walkthrough ```mermaid flowchart LR A["Bazel BUILD.bazel"] --> B["Replace default features"] B --> C["Add explicit feature flags"] D["Dockerfile"] --> E["Improve dependency caching"] E --> F["Add locked builds"] ``` <details> <summary><h3> File Walkthrough</h3></summary> <table><thead><tr><th></th><th align="left">Relevant files</th></tr></thead><tbody><tr><td><strong>Configuration changes</strong></td><td><table> <tr> <td> <details> <summary><strong>BUILD.bazel</strong><dd><code>Replace default features with explicit flags</code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </dd></summary> <hr> cmd/flowgger/BUILD.bazel <ul><li>Replace "default" feature with explicit feature flags<br> <li> Add gelf, passthrough, rfc3164, rfc5424, syslog, tls features<br> <li> Apply changes to both rust_library and rust_binary targets</ul> </details> </td> <td><a href="https://github.com/carverauto/serviceradar/pull/1718/files#diff-e0d27194757d8bbbfba44ac2d6b074f78fce8a879099e15c4a612ed03056504c">+12/-2</a>&nbsp; &nbsp; </td> </tr> <tr> <td> <details> <summary><strong>Dockerfile</strong><dd><code>Improve Docker build caching and reproducibility</code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </dd></summary> <hr> cmd/flowgger/Dockerfile <ul><li>Copy actual workspace contents instead of stub files<br> <li> Add Cargo.lock and build.rs to dependency layer<br> <li> Use --locked flag for reproducible builds<br> <li> Specify explicit features matching Bazel configuration</ul> </details> </td> <td><a href="https://github.com/carverauto/serviceradar/pull/1718/files#diff-7199f3111d0ff4e1154dd5a0f2250ea0e82c39031abdf7864356570dd1007c87">+12/-17</a>&nbsp; </td> </tr> </table></td></tr></tr></tbody></table> </details> ___
qodo-code-review[bot] commented 2025-10-06 02:13:26 +00:00 (Migrated from github.com)
Author
Owner

Imported GitHub PR comment.

Original author: @qodo-code-review[bot]
Original URL: https://github.com/carverauto/serviceradar/pull/1718#issuecomment-3369701966
Original created: 2025-10-06T02:13:26Z

PR Compliance Guide 🔍

Below is a summary of compliance checks for this PR:

Security Compliance
🟢
No security concerns identified No security vulnerabilities detected by AI analysis. Human verification advised for critical code.
Ticket Compliance
🎫 No ticket provided
  • Create ticket/issue
Codebase Duplication Compliance
Codebase context is not defined

Follow the guide to enable codebase context checks.

Custom Compliance
No custom compliance provided

Follow the guide to enable custom compliance check.

Compliance status legend 🟢 - Fully Compliant
🟡 - Partial Compliant
🔴 - Not Compliant
- Requires Further Human Verification
🏷️ - Compliance label
Imported GitHub PR comment. Original author: @qodo-code-review[bot] Original URL: https://github.com/carverauto/serviceradar/pull/1718#issuecomment-3369701966 Original created: 2025-10-06T02:13:26Z --- ## PR Compliance Guide 🔍 <!-- https://github.com/carverauto/serviceradar/commit/b2afede1e7c40f9aee5d5b59844d6cb9ffd0806c --> Below is a summary of compliance checks for this PR:<br> <table><tbody><tr><td colspan='2'><strong>Security Compliance</strong></td></tr> <tr><td>🟢</td><td><details><summary><strong>No security concerns identified</strong></summary> No security vulnerabilities detected by AI analysis. Human verification advised for critical code. </details></td></tr> <tr><td colspan='2'><strong>Ticket Compliance</strong></td></tr> <tr><td>⚪</td><td><details><summary>🎫 <strong>No ticket provided </summary></strong> - [ ] Create ticket/issue <!-- /create_ticket --create_ticket=true --> </details></td></tr> <tr><td colspan='2'><strong>Codebase Duplication Compliance</strong></td></tr> <tr><td>⚪</td><td><details><summary><strong>Codebase context is not defined </strong></summary> Follow the <a href='https://qodo-merge-docs.qodo.ai/core-abilities/rag_context_enrichment/'>guide</a> to enable codebase context checks. </details></td></tr> <tr><td colspan='2'><strong>Custom Compliance</strong></td></tr> <tr><td>⚪</td><td><details><summary><strong>No custom compliance provided</strong></summary> Follow the <a href='https://qodo-merge-docs.qodo.ai/tools/compliance/'>guide</a> to enable custom compliance check. </details></td></tr> <tr><td align="center" colspan="2"> <!-- placeholder --> <!-- /compliance --update_compliance=true --> </td></tr></tbody></table> <details><summary>Compliance status legend</summary> 🟢 - Fully Compliant<br> 🟡 - Partial Compliant<br> 🔴 - Not Compliant<br> ⚪ - Requires Further Human Verification<br> 🏷️ - Compliance label<br> </details>
qodo-code-review[bot] commented 2025-10-06 02:14:28 +00:00 (Migrated from github.com)
Author
Owner

Imported GitHub PR comment.

Original author: @qodo-code-review[bot]
Original URL: https://github.com/carverauto/serviceradar/pull/1718#issuecomment-3369703334
Original created: 2025-10-06T02:14:28Z

PR Code Suggestions

Explore these optional code suggestions:

CategorySuggestion                                                                                                                                    Impact
High-level
Unify build configuration to avoid duplication

The list of crate features is duplicated in both BUILD.bazel and the Dockerfile,
creating a maintenance risk. To resolve this, consider using Bazel as the single
source of truth for building the Docker image.

Examples:

cmd/flowgger/BUILD.bazel [50-58]
    crate_features = [
        "gelf",
        "nats-output",
        "passthrough",
        "rfc3164",
        "rfc5424",
        "syslog",
        "tls",
    ],
cmd/flowgger/Dockerfile [36]
        --features "gelf nats-output passthrough rfc3164 rfc5424 syslog tls" \

Solution Walkthrough:

Before:

# cmd/flowgger/BUILD.bazel
rust_binary(
    name = "flowgger",
    crate_features = [
        "gelf",
        "nats-output",
        "passthrough",
        "rfc3164",
        ...
    ],
)

# cmd/flowgger/Dockerfile
RUN cargo build \
    --features "gelf nats-output passthrough rfc3164 ..." \
    ...

After:

# cmd/flowgger/BUILD.bazel
load("@io_bazel_rules_docker//rust:image.bzl", "rust_image")

rust_binary(
    name = "flowgger",
    crate_features = [
        "gelf",
        "nats-output",
        "passthrough",
        "rfc3164",
        ...
    ],
)

rust_image(
    name = "flowgger_image",
    binary = ":flowgger",
)
# Dockerfile is no longer needed for building

Suggestion importance[1-10]: 8

__

Why: The suggestion correctly identifies significant configuration duplication for crate features between BUILD.bazel and the Dockerfile, which introduces a maintenance risk for build consistency.

Medium
  • More
Imported GitHub PR comment. Original author: @qodo-code-review[bot] Original URL: https://github.com/carverauto/serviceradar/pull/1718#issuecomment-3369703334 Original created: 2025-10-06T02:14:28Z --- ## PR Code Suggestions ✨ <!-- b2afede --> Explore these optional code suggestions: <table><thead><tr><td><strong>Category</strong></td><td align=left><strong>Suggestion&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </strong></td><td align=center><strong>Impact</strong></td></tr><tbody><tr><td rowspan=1>High-level</td> <td> <details><summary>Unify build configuration to avoid duplication</summary> ___ **The list of crate features is duplicated in both <code>BUILD.bazel</code> and the <code>Dockerfile</code>, <br>creating a maintenance risk. To resolve this, consider using Bazel as the single <br>source of truth for building the Docker image.** ### Examples: <details> <summary> <a href="https://github.com/carverauto/serviceradar/pull/1718/files#diff-e0d27194757d8bbbfba44ac2d6b074f78fce8a879099e15c4a612ed03056504cR50-R58">cmd/flowgger/BUILD.bazel [50-58]</a> </summary> ```starlark crate_features = [ "gelf", "nats-output", "passthrough", "rfc3164", "rfc5424", "syslog", "tls", ], ``` </details> <details> <summary> <a href="https://github.com/carverauto/serviceradar/pull/1718/files#diff-7199f3111d0ff4e1154dd5a0f2250ea0e82c39031abdf7864356570dd1007c87R36-R36">cmd/flowgger/Dockerfile [36]</a> </summary> ```dockerfile --features "gelf nats-output passthrough rfc3164 rfc5424 syslog tls" \ ``` </details> ### Solution Walkthrough: #### Before: ```dockerfile # cmd/flowgger/BUILD.bazel rust_binary( name = "flowgger", crate_features = [ "gelf", "nats-output", "passthrough", "rfc3164", ... ], ) # cmd/flowgger/Dockerfile RUN cargo build \ --features "gelf nats-output passthrough rfc3164 ..." \ ... ``` #### After: ```dockerfile # cmd/flowgger/BUILD.bazel load("@io_bazel_rules_docker//rust:image.bzl", "rust_image") rust_binary( name = "flowgger", crate_features = [ "gelf", "nats-output", "passthrough", "rfc3164", ... ], ) rust_image( name = "flowgger_image", binary = ":flowgger", ) # Dockerfile is no longer needed for building ``` <details><summary>Suggestion importance[1-10]: 8</summary> __ Why: The suggestion correctly identifies significant configuration duplication for crate features between `BUILD.bazel` and the `Dockerfile`, which introduces a maintenance risk for build consistency. </details></details></td><td align=center>Medium </td></tr> <tr><td align="center" colspan="2"> - [ ] More <!-- /improve --more_suggestions=true --> </td><td></td></tr></tbody></table>
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
carverauto/serviceradar!2289
No description provided.