Skip to content

Conversation

@mshriver
Copy link
Contributor

@mshriver mshriver commented Dec 17, 2025

run all the containers with locally built images to be able to test the builds and built containers within the local test environment.

Summary by Sourcery

Add a new option to ibutsu-pod.sh to run the local stack using pre-built container images instead of development mounts, including support for building and tagging those images from the current Git branch.

New Features:

  • Introduce a --images/-i flag to ibutsu-pod.sh to toggle between runtime dev mounts and locally built container images.
  • Add a build_images helper that builds backend, worker, scheduler, flower, and frontend images tagged with the current Git branch name.

Enhancements:

  • Update podman run commands for backend, worker, scheduler, flower, and frontend services to conditionally use either local images or development mounts based on the new flag.
  • Improve script output with a summary indicating whether local images or dev mounts are being used and clearer lifecycle messages for services.

Copilot AI review requested due to automatic review settings December 17, 2025 15:28
@sourcery-ai
Copy link
Contributor

sourcery-ai bot commented Dec 17, 2025

Reviewer's Guide

Adds a new --images mode to ibutsu-pod.sh that builds and runs locally tagged Podman images for backend, worker, scheduler, flower, and frontend instead of using runtime dev mounts, while keeping existing dev behavior as the default.

Sequence diagram for ibutsu-pod.sh startup with and without --images

sequenceDiagram
    actor Developer
    participant Script as ibutsu_pod_sh
    participant Git as git_repo
    participant Podman as podman

    rect rgb(230,230,230)
        Note over Developer,Script: Default mode (runtime dev mounts)
        Developer->>Script: run ./ibutsu-pod.sh
        Script->>Script: parse_args (USE_IMAGES=false)
        Script->>Podman: create pod and infra containers
        Script->>Podman: run backend using python_base + bind mount
        Script->>Podman: run worker using python_base + bind mount
        Script->>Podman: run scheduler using python_base + bind mount
        Script->>Podman: run flower using python_base + bind mount
        Script->>Podman: run frontend using node_base + bind mount
        Script->>Podman: wait for backend and frontend health
    end

    rect rgb(220,240,255)
        Note over Developer,Script: New --images mode (locally built images)
        Developer->>Script: run ./ibutsu-pod.sh --images
        Script->>Script: parse_args (USE_IMAGES=true)
        Script->>Git: git_rev_parse_current_branch
        Git-->>Script: IMAGE_TAG
        Script->>Podman: build ibutsu-backend:IMAGE_TAG
        Script->>Podman: build ibutsu-worker:IMAGE_TAG
        Script->>Podman: build ibutsu-scheduler:IMAGE_TAG
        Script->>Podman: build ibutsu-flower:IMAGE_TAG
        Script->>Podman: build ibutsu-frontend:IMAGE_TAG
        Script->>Podman: create pod and infra containers
        Script->>Podman: run ibutsu-backend:IMAGE_TAG
        Script->>Podman: run ibutsu-worker:IMAGE_TAG
        Script->>Podman: run ibutsu-scheduler:IMAGE_TAG
        Script->>Podman: run ibutsu-flower:IMAGE_TAG
        Script->>Podman: run ibutsu-frontend:IMAGE_TAG
        Script->>Podman: wait for backend and frontend health
    end
Loading

File-Level Changes

Change Details Files
Introduce a --images flag and USE_IMAGES toggle to control whether ibutsu-pod uses locally built images or dev-time mounts.
  • Add USE_IMAGES variable defaulting to false and extend CLI usage/help text to describe the new -i/--images option.
  • Parse -i/--images in the argument loop to set USE_IMAGES=true.
  • Print a summary line indicating whether local images or dev mounts are being used.
scripts/ibutsu-pod.sh
Add build_images helper to build backend, worker, scheduler, flower, and frontend Podman images tagged by current git branch (or 'local').
  • Implement build_images() function that derives IMAGE_TAG from current git branch name (sanitized) or defaults to 'local'.
  • Within build_images(), build four backend-related images (backend, worker, scheduler, flower) from backend/docker Dockerfiles, and one frontend image from frontend/docker/Dockerfile.frontend, with error handling and directory pushd/popd.
  • When USE_IMAGES is true, set IMAGE_TAG and call build_images early in script after repo layout validation.
scripts/ibutsu-pod.sh
Conditionally run backend, worker, scheduler, flower, and frontend containers using either built images or the previous dev mount approach.
  • Wrap backend podman run in a USE_IMAGES check: in image mode, run ibutsu-backend:${IMAGE_TAG} (no code volume mount) executing init_db then starting gunicorn; otherwise keep existing PYTHON_IMAGE dev flow with /mnt mount and uvicorn reload.
  • Wrap worker container creation: in image mode, run ibutsu-worker:${IMAGE_TAG}; otherwise retain current dev mount flow that installs the backend package and starts celery worker.
  • Introduce a new celery scheduler container: in image mode run ibutsu-scheduler:${IMAGE_TAG}; otherwise run a dev-mode container that installs the backend package and executes celery beat.
  • Wrap flower container creation: in image mode, run ibutsu-flower:${IMAGE_TAG} with CELERY_BROKER_URL; otherwise keep dev mount flow that installs flower and runs celery flower with BROKER_URL.
  • Wrap frontend container creation: in image mode run ibutsu-frontend:${IMAGE_TAG} with REACT_APP_SERVER_URL and yarn start on the pod frontend port; otherwise keep existing Node devserver container with bind-mounted frontend and yarn devserver.
scripts/ibutsu-pod.sh

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

Copy link
Contributor

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

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

Hey there - I've reviewed your changes - here's some feedback:

  • The IMAGE_TAG calculation is duplicated in both build_images() and the main --images branch; consider computing it once (near option parsing) and reusing the same variable to keep tag selection consistent and easier to adjust.
  • The podman run blocks for backend, worker, scheduler, flower, and frontend now have large duplicated sections between the USE_IMAGES=true/false branches; extracting small helper functions or shared argument arrays would reduce repetition and make future changes less error-prone.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- The IMAGE_TAG calculation is duplicated in both build_images() and the main --images branch; consider computing it once (near option parsing) and reusing the same variable to keep tag selection consistent and easier to adjust.
- The podman run blocks for backend, worker, scheduler, flower, and frontend now have large duplicated sections between the USE_IMAGES=true/false branches; extracting small helper functions or shared argument arrays would reduce repetition and make future changes less error-prone.

## Individual Comments

### Comment 1
<location> `scripts/ibutsu-pod.sh:49-58` </location>
<code_context>
     echo ""
 }

+# Function to build container images locally
+function build_images() {
+    echo "================================="
+    echo "Building container images..."
+
+    # Get the current git branch name for image tagging
+    IMAGE_TAG=$(git rev-parse --abbrev-ref HEAD 2>/dev/null | tr '/' '-')
+    if [[ -z "$IMAGE_TAG" ]]; then
+        IMAGE_TAG="local"
+    fi
+    echo "Using image tag: ${IMAGE_TAG}"
+
+    # Build backend images from the backend directory
</code_context>

<issue_to_address>
**suggestion:** Avoid duplicating IMAGE_TAG resolution logic between build_images and the main flow

IMAGE_TAG is computed inside build_images and again near the `if [[ $USE_IMAGES = true ]]` block, leading to two slightly different implementations of the same logic. Centralize this into a helper or compute IMAGE_TAG once near the top of the script so both build_images and the run path share a single, consistent value.

Suggested implementation:

```
    echo ""
}

# Resolve IMAGE_TAG once so it can be reused across the script
function resolve_image_tag() {
    if [[ -n "${IMAGE_TAG:-}" ]]; then
        # Respect pre-set IMAGE_TAG (from environment or caller)
        return
    fi

    local git_branch
    git_branch=$(git rev-parse --abbrev-ref HEAD 2>/dev/null | tr '/' '-') || git_branch=""

    if [[ -n "$git_branch" ]]; then
        IMAGE_TAG="$git_branch"
    else
        IMAGE_TAG="local"
    fi
}

# Function to build container images locally
function build_images() {

```

```
    echo "================================="
    echo "Building container images..."

    # Ensure IMAGE_TAG is resolved once and reused
    resolve_image_tag
    echo "Using image tag: ${IMAGE_TAG}"

```

To fully remove duplication, the other place in this script where `IMAGE_TAG` is computed (near the `if [[ $USE_IMAGES = true ]]` block) should be updated to **call `resolve_image_tag` instead of recomputing it inline**. For example, replace the inline `git rev-parse` / defaulting logic there with:

```bash
resolve_image_tag
# then use $IMAGE_TAG
```

This will ensure a single, consistent implementation of image tag resolution shared by both the build and run paths.
</issue_to_address>

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

@mshriver mshriver force-pushed the ibutsu-pod-with-images branch 2 times, most recently from ed30bd4 to ae3351f Compare December 17, 2025 15:36
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR adds a --images (or -i) flag to the ibutsu-pod.sh script that enables building and using locally-built container images instead of mounting source directories at runtime. This allows testing containerized builds in the local development environment.

Key changes:

  • Added build_images() function that builds all five container images (backend, worker, scheduler, flower, frontend) from local Dockerfiles
  • Modified all container run commands to conditionally use pre-built images or runtime dev mounts based on the new USE_IMAGES flag
  • Added celery scheduler container to the pod setup (previously missing from the script)
Comments suppressed due to low confidence (1)

scripts/ibutsu-pod.sh:180

  • The 'git' command is used to generate IMAGE_TAG but is not included in the list of required tools checked at line 163. While the command has error handling (2>/dev/null and fallback to "local"), users without git installed would silently fallback to "local" tag without knowing git is missing. Consider either adding 'git' to the required tools list, or adding a warning message when git is not available.
            else

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@codecov
Copy link

codecov bot commented Dec 17, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 64.81%. Comparing base (0d3a733) to head (e9b5061).
⚠️ Report is 1 commits behind head on main.

❌ Your project status has failed because the head coverage (64.81%) is below the target coverage (85.00%). You can increase the head coverage or adjust the target coverage.

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #796   +/-   ##
=======================================
  Coverage   64.81%   64.81%           
=======================================
  Files         157      157           
  Lines        7633     7633           
  Branches      659      659           
=======================================
  Hits         4947     4947           
  Misses       2467     2467           
  Partials      219      219           

Continue to review full report in Codecov by Sentry.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 0d3a733...e9b5061. Read the comment docs.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

run all the containers with locally built images to be able to test the
builds and built containers within the local test environment.
@mshriver mshriver force-pushed the ibutsu-pod-with-images branch from ae3351f to e9b5061 Compare December 17, 2025 16:06
@mshriver mshriver merged commit 0fa1ca5 into ibutsu:main Dec 23, 2025
14 of 15 checks passed
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.

1 participant