Skip to content

ci: fix Docker tag format and add version pinning for transport builds#132

Merged
akshaydeo merged 1 commit intomainfrom
06-26-bug_docker_push_ci_version_issue_fixes
Jun 26, 2025
Merged

ci: fix Docker tag format and add version pinning for transport builds#132
akshaydeo merged 1 commit intomainfrom
06-26-bug_docker_push_ci_version_issue_fixes

Conversation

@Pratham-Mishra04
Copy link
Copy Markdown
Collaborator

Fix Docker image versioning and add tag-based dependency resolution

This PR improves the Docker image build process for transports in two key ways:

  1. Fixes the Docker image tag format by:

    • Preserving the 'v' prefix in version numbers
    • Properly extracting the version from tags (removing only the 'transports/' prefix)
    • Adding a separate step to extract the numeric version for validation
  2. Adds tag-based dependency resolution:

    • Introduces a new TAG_VERSION build argument to the Dockerfile
    • Passes the extracted version from the GitHub workflow to the Dockerfile
    • Updates the Go dependency resolution to use the specific tagged version instead of always using 'latest'

These changes ensure that when building a specific transport version, the Docker image will use the matching tagged version of the bifrost dependency rather than always pulling the latest version.

Copy link
Copy Markdown
Collaborator Author

This stack of pull requests is managed by Graphite. Learn more about stacking.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Jun 26, 2025

Summary by CodeRabbit

  • New Features

    • Added support for specifying a custom version of the bifrost transport module during Docker image builds.
  • Chores

    • Improved version extraction and validation in the CI workflow for more accurate Docker image tagging.
    • Updated Docker build process to use the extracted version as a build argument.

Walkthrough

The changes update the transport build workflow and Dockerfile to improve version handling. The workflow now extracts and validates the version from tags more precisely, outputs it for later steps, and passes it as a build argument to Docker. The Dockerfile uses this argument to fetch the correct module version during the build.

Changes

File(s) Change Summary
.github/workflows/transport-ci.yml Refined version extraction and validation; outputs version; passes version as Docker build arg.
transports/Dockerfile Added TAG_VERSION build argument; updated go get to use this argument for module versioning.

Sequence Diagram(s)

sequenceDiagram
    participant GitHub Actions
    participant Docker Build
    participant Dockerfile
    participant Go Module Proxy

    GitHub Actions->>GitHub Actions: Extract and validate version from tag
    GitHub Actions->>Docker Build: Pass TAG_VERSION as build argument
    Docker Build->>Dockerfile: Build with ARG TAG_VERSION
    Dockerfile->>Go Module Proxy: go get bifrost module @TAG_VERSION
    Go Module Proxy-->>Dockerfile: Return specified module version
    Dockerfile-->>Docker Build: Complete build with correct module
Loading

Possibly related PRs

Suggested reviewers

  • danpiths
  • akshaydeo

Poem

In the warren of Docker and tags so neat,
A version hops in, no longer obsolete.
With ARGs in its pocket and workflows anew,
The transport builds fresh, not just the latest brew.
🐇✨ Now every hop finds the right code to greet!

✨ Finishing Touches
🧪 Generate Unit Tests
  • Create PR with Unit Tests
  • Post Copyable Unit Tests in Comment
  • Commit Unit Tests in branch 06-26-bug_docker_push_ci_version_issue_fixes

🪧 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.
    • Explain this complex logic.
    • 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 explain this code block.
    • @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 explain its main purpose.
    • @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.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

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.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai auto-generate unit tests to generate unit tests for this PR.
  • @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.

Copy link
Copy Markdown
Contributor

@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: 4

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 225430a and 32c10c2.

📒 Files selected for processing (2)
  • .github/workflows/transport-ci.yml (2 hunks)
  • transports/Dockerfile (1 hunks)

Comment thread transports/Dockerfile
Comment on lines +13 to +17
ARG TAG_VERSION=latest

# Initialize go module and get bifrost-http
# Initialize go module and get bifrost with specified tag
RUN go mod init bifrost-build && \
go get github.com/maximhq/bifrost/transports/bifrost-${TRANSPORT_TYPE}@latest
go get github.com/maximhq/bifrost/transports/bifrost-${TRANSPORT_TYPE}@${TAG_VERSION}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🧹 Nitpick (assertive)

Consider switching from go get to go install (or go mod download) for reproducible, forward-compatible builds

go get mutates go.mod/go.sum and has been discouraged for fetching binaries since Go 1.20.
Using go install (for direct binary installation) or a plain go mod download && go build keeps the module graph immutable and avoids the deprecation warning that will soon turn into an error.

-ARG TAG_VERSION=latest
-# Initialize go module and get bifrost with specified tag
-RUN go mod init bifrost-build && \
-    go get github.com/maximhq/bifrost/transports/bifrost-${TRANSPORT_TYPE}@${TAG_VERSION}
+# Explicit module initialisation
+ARG TAG_VERSION=latest
+RUN go mod init bifrost-build && \
+    go mod tidy && \
+    go install github.com/maximhq/bifrost/transports/bifrost-${TRANSPORT_TYPE}@${TAG_VERSION} && \
+    go mod download

This keeps the Docker layer deterministic, avoids side-effects in go.mod, and aligns with the Go tooling roadmap.

📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
ARG TAG_VERSION=latest
# Initialize go module and get bifrost-http
# Initialize go module and get bifrost with specified tag
RUN go mod init bifrost-build && \
go get github.com/maximhq/bifrost/transports/bifrost-${TRANSPORT_TYPE}@latest
go get github.com/maximhq/bifrost/transports/bifrost-${TRANSPORT_TYPE}@${TAG_VERSION}
ARG TAG_VERSION=latest
# Explicit module initialization
RUN go mod init bifrost-build && \
go mod tidy && \
go install github.com/maximhq/bifrost/transports/bifrost-${TRANSPORT_TYPE}@${TAG_VERSION} && \
go mod download
🤖 Prompt for AI Agents
In transports/Dockerfile around lines 13 to 17, replace the use of 'go get' with
'go install' or 'go mod download' followed by 'go build' to fetch the bifrost
module. This avoids mutating go.mod and go.sum files during the Docker build,
ensuring reproducible and forward-compatible builds. Adjust the commands to
install or build the binary without changing the module graph, maintaining
deterministic Docker layers and preventing future deprecation errors.

Comment on lines 162 to 165
echo "tags<<EOF" >> $GITHUB_OUTPUT
echo "${{ env.REGISTRY }}/${{ env.ACCOUNT }}/${{ env.IMAGE_NAME }}:v${VERSION}" >> $GITHUB_OUTPUT
echo "${{ env.REGISTRY }}/${{ env.ACCOUNT }}/${{ env.IMAGE_NAME }}:${VERSION}" >> $GITHUB_OUTPUT
echo "${{ env.REGISTRY }}/${{ env.ACCOUNT }}/${{ env.IMAGE_NAME }}:latest" >> $GITHUB_OUTPUT
echo "EOF" >> $GITHUB_OUTPUT
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🧹 Nitpick (assertive)

Use the official multi-line $GITHUB_OUTPUT syntax to avoid missing delimiter errors

Manually echoing the tags<<EOF … EOF sequence is error-prone.
The recommended pattern is:

{
  echo 'tags<<EOF'
  echo "${{ env.REGISTRY }}/${{ env.ACCOUNT }}/${{ env.IMAGE_NAME }}:${VERSION}"
  echo "${{ env.REGISTRY }}/${{ env.ACCOUNT }}/${{ env.IMAGE_NAME }}:latest"
  echo 'EOF'
} >>"$GITHUB_OUTPUT"

Wrapping the block in braces guarantees the heredoc is kept together and reduces chances of accidental redirection mistakes during future edits.

🤖 Prompt for AI Agents
In .github/workflows/transport-ci.yml around lines 162 to 165, replace the
multiple echo commands appending to $GITHUB_OUTPUT individually with a single
block wrapped in braces that echoes the heredoc lines together. This ensures the
multi-line output is written atomically and prevents missing delimiter errors by
grouping the echo statements inside braces and redirecting their combined output
once to $GITHUB_OUTPUT.

Comment on lines 198 to +199
TRANSPORT_TYPE=http
TAG_VERSION=${{ steps.meta.outputs.version }}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🧹 Nitpick (assertive)

Minor: keep build-arg list transport-agnostic

TRANSPORT_TYPE=http is hard-coded here while the rest of the pipeline is tag-driven. When a non-HTTP transport is tagged this step will still label the image “HTTP”, risking confusion.

Consider:

build-args: |
  TRANSPORT_TYPE=${{ env.TRANSPORT_TYPE }}
  TAG_VERSION=${{ steps.meta.outputs.version }}

and source TRANSPORT_TYPE from the tag or job matrix to stay future-proof.

🤖 Prompt for AI Agents
In .github/workflows/transport-ci.yml at lines 198-199, the TRANSPORT_TYPE build
argument is hard-coded to "http", which conflicts with the tag-driven approach
and can cause confusion for non-HTTP transports. Update the build-args to use
TRANSPORT_TYPE from the environment variable instead, like TRANSPORT_TYPE=${{
env.TRANSPORT_TYPE }}, and ensure TRANSPORT_TYPE is set appropriately from the
tag or job matrix to keep the pipeline transport-agnostic and future-proof.

Comment on lines +148 to +156
# Extract version from tag (remove transports/ prefix)
VERSION=${TAG#transports/}
echo "version=${VERSION}" >> $GITHUB_OUTPUT

# Extract numeric version for validation
NUMERIC_VERSION=${VERSION#v}

# Validate version format
if ! echo "$VERSION" | grep -qE '^[0-9]+\.[0-9]+\.[0-9]+$'; then
if ! echo "$NUMERIC_VERSION" | grep -qE '^[0-9]+\.[0-9]+\.[0-9]+$'; then
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Path-traversal & whitespace hardening for extracted version

VERSION=${TAG#transports/} and NUMERIC_VERSION=${VERSION#v} rely on the incoming tag being perfectly formed.
If a malicious (or simply mistyped) tag like transports/v1.2.3$(printf '\nX') were pushed, the newline would bleed into subsequent echo >> $GITHUB_OUTPUT lines and break the workflow / poison the build args.

Add simple sanitation:

VERSION=${TAG#transports/}
VERSION=${VERSION//$'\n'/}     # strip newlines
VERSION=${VERSION//$'\r'/}     # strip carriage returns

or use printf '%s\n' instead of bare echo when writing to $GITHUB_OUTPUT.

Tiny change – big safety net.

🤖 Prompt for AI Agents
In .github/workflows/transport-ci.yml around lines 148 to 156, the extraction of
VERSION and NUMERIC_VERSION from TAG does not sanitize input, allowing newlines
or carriage returns to corrupt the output and break the workflow. To fix this,
after extracting VERSION, strip any newline and carriage return characters from
it using parameter expansion to remove $'\n' and $'\r'. Alternatively, replace
the bare echo commands writing to $GITHUB_OUTPUT with printf '%s\n' to safely
handle special characters. This sanitization prevents path traversal and
whitespace injection issues.

@akshaydeo akshaydeo marked this pull request as ready for review June 26, 2025 09:10
@akshaydeo akshaydeo merged commit c559c93 into main Jun 26, 2025
1 check passed
@akshaydeo akshaydeo deleted the 06-26-bug_docker_push_ci_version_issue_fixes branch August 31, 2025 17:30
akshaydeo added a commit that referenced this pull request Nov 17, 2025
#132)

# Fix Docker image versioning and add tag-based dependency resolution

This PR improves the Docker image build process for transports in two key ways:

1. Fixes the Docker image tag format by:
   - Preserving the 'v' prefix in version numbers
   - Properly extracting the version from tags (removing only the 'transports/' prefix)
   - Adding a separate step to extract the numeric version for validation

2. Adds tag-based dependency resolution:
   - Introduces a new `TAG_VERSION` build argument to the Dockerfile
   - Passes the extracted version from the GitHub workflow to the Dockerfile
   - Updates the Go dependency resolution to use the specific tagged version instead of always using 'latest'

These changes ensure that when building a specific transport version, the Docker image will use the matching tagged version of the bifrost dependency rather than always pulling the latest version.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants