Skip to content

feat: Add support for custom llama.cpp base image and forked llama-swap repositories#396

Merged
mostlygeek merged 2 commits intomostlygeek:mainfrom
ryan-steed-usa:flexible-container-build
Nov 30, 2025
Merged

feat: Add support for custom llama.cpp base image and forked llama-swap repositories#396
mostlygeek merged 2 commits intomostlygeek:mainfrom
ryan-steed-usa:flexible-container-build

Conversation

@ryan-steed-usa
Copy link
Copy Markdown
Contributor

@ryan-steed-usa ryan-steed-usa commented Nov 11, 2025

  • Introduce BASE_LLAMACPP_IMAGE env var to customize llama.cpp base image
  • Introduce LS_REPO env var to customize llama-swap source
  • Use GITHUB_REPOSITORY env var to automatically detect forked repos
  • Update container tagging to use dynamic repo paths
  • Pass build args for BASE_IMAGE and LS_REPO to Containerfile
  • Enable flexible release downloads from forked repositories

@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Nov 11, 2025

Walkthrough

Replaces hardcoded base image and repository references with configurable ARGs/variables in the Docker build script and Containerfile; adds build-arg propagation, non-root user setup (UID, GID, USER_HOME, HOME), HEALTHCHECK, and ENTRYPOINT to the container image.

Changes

Cohort / File(s) Summary
Build script parameterization
docker/build-container.sh
Introduced environment-driven variables (BASE_IMAGE via BASE_LLAMACPP_IMAGE, LS_REPO via GITHUB_REPOSITORY); fetches latest release from https://api.github.com/repos/${LS_REPO}/releases/latest; updated CONTAINER_TAG/CONTAINER_LATEST to use ${LS_REPO}; added --build-arg LS_REPO=${LS_REPO} and --build-arg BASE_IMAGE=${BASE_IMAGE} to build invocation.
Containerfile base/image indirection
docker/llama-swap.Containerfile
Added ARG BASE_IMAGE and switched FROM to FROM ${BASE_IMAGE}:${BASE_TAG}; added ARG LS_REPO and used it for download URLs and tar extraction paths.
Non-root runtime setup
docker/llama-swap.Containerfile
Added public ARGs UID, GID, USER_HOME and ENV HOME; created group/user, set up directories and ownership, copied config, removed extracted tarball, and switched to non-root user.
Runtime behavior & health
docker/llama-swap.Containerfile
Added HEALTHCHECK directive and ENTRYPOINT to run llama-swap with /app/config.yaml; retained COPY of example config to /app/config.yaml.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

  • Verify replacement of hardcoded mostlygeek/llama-swap occurrences with ${LS_REPO} across build and Containerfile.
  • Validate default ARG values and that --build-arg propagation matches build-time expectations.
  • Check user creation, directory ownership, and cleanup order (tarball extraction/removal) in the Containerfile.

Possibly related PRs

Pre-merge checks and finishing touches

✅ Passed checks (3 passed)
Check name Status Explanation
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately summarizes the main changes: adding support for custom base images and forked repositories, which are the primary features introduced in this PR.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown

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

🧹 Nitpick comments (1)
docker/build-container.sh (1)

54-54: Consider passing BASE_IMAGE for complete flexibility.

The Containerfile defines ARG BASE_IMAGE with a default, but the build script doesn't pass it as a build-arg. While this works due to the default value, adding --build-arg BASE_IMAGE=${BASE_IMAGE:-ghcr.io/ggml-org/llama.cpp} would provide full control over the base image via the script, completing the flexibility improvements from this PR.

📜 Review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 3567b7d and 9f38155.

📒 Files selected for processing (4)
  • .github/workflows/release.yml (2 hunks)
  • .goreleaser.yaml (2 hunks)
  • docker/build-container.sh (2 hunks)
  • docker/llama-swap.Containerfile (2 hunks)
🧰 Additional context used
🧠 Learnings (3)
📓 Common learnings
Learnt from: ryan-steed-usa
Repo: mostlygeek/llama-swap PR: 391
File: docker/build-container.sh:29-32
Timestamp: 2025-11-08T16:56:35.618Z
Learning: In the mostlygeek/llama-swap repository, llama.cpp container tags from ghcr.io/ggml-org/llama.cpp use build identifiers (e.g., `b6981`) rather than semantic versions. The tag format is `server-<something>-<build-id>` for cpu and `server-<arch>-<something>-<build-id>` for other architectures, where extracting the third field with `awk -F '-' '{print $3}'` correctly retrieves the build identifier.
Learnt from: ryan-steed-usa
Repo: mostlygeek/llama-swap PR: 368
File: docker/llama-swap.Containerfile:14-20
Timestamp: 2025-10-27T16:04:23.381Z
Learning: In docker/llama-swap.Containerfile, the user/group creation logic intentionally supports adding a non-root user (non-zero UID) to the root group (GID=0) as a valid configuration. This allows flexible UID/GID customization where users can specify only a UID or both UID and GID.
📚 Learning: 2025-11-08T16:56:35.618Z
Learnt from: ryan-steed-usa
Repo: mostlygeek/llama-swap PR: 391
File: docker/build-container.sh:29-32
Timestamp: 2025-11-08T16:56:35.618Z
Learning: In the mostlygeek/llama-swap repository, llama.cpp container tags from ghcr.io/ggml-org/llama.cpp use build identifiers (e.g., `b6981`) rather than semantic versions. The tag format is `server-<something>-<build-id>` for cpu and `server-<arch>-<something>-<build-id>` for other architectures, where extracting the third field with `awk -F '-' '{print $3}'` correctly retrieves the build identifier.

Applied to files:

  • docker/build-container.sh
  • docker/llama-swap.Containerfile
📚 Learning: 2025-10-27T16:04:23.381Z
Learnt from: ryan-steed-usa
Repo: mostlygeek/llama-swap PR: 368
File: docker/llama-swap.Containerfile:14-20
Timestamp: 2025-10-27T16:04:23.381Z
Learning: In docker/llama-swap.Containerfile, the user/group creation logic intentionally supports adding a non-root user (non-zero UID) to the root group (GID=0) as a valid configuration. This allows flexible UID/GID customization where users can specify only a UID or both UID and GID.

Applied to files:

  • docker/build-container.sh
  • docker/llama-swap.Containerfile
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
  • GitHub Check: run-tests
  • GitHub Check: run-tests
🔇 Additional comments (5)
.github/workflows/release.yml (1)

21-22: LGTM! GO111MODULE configuration aligns with goreleaser.

The environment variable setup correctly uses the repository variable with a safe 'auto' fallback, coordinating with the .goreleaser.yaml configuration to ensure consistent Go module handling during releases.

docker/build-container.sh (1)

23-24: LGTM! Repository parameterization implemented correctly.

The LS_REPO variable is well-designed, sourcing from GITHUB_REPOSITORY with a sensible default that maintains backward compatibility.

docker/llama-swap.Containerfile (2)

1-3: LGTM! Base image parameterization enhances flexibility.

The BASE_IMAGE and BASE_TAG arguments with appropriate defaults enable custom base images while maintaining backward compatibility.


7-7: LGTM! Repository parameterization supports forked releases.

The LS_REPO argument correctly enables downloading llama-swap binaries from custom repositories, aligning with the PR's goal of supporting forked builds.

.goreleaser.yaml (1)

3-4: LGTM! GO111MODULE template configured correctly.

The goreleaser template syntax properly checks for the environment variable and provides a sensible 'auto' default, coordinating with the workflow configuration to enable flexible Go module mode handling for custom builds.

…ap repositories

- Introduce BASE_LLAMACPP_IMAGE env var to customize llama.cpp base image
- Introduce LS_REPO env var to customize llama-swap source
- Use GITHUB_REPOSITORY env var to automatically detect forked repos
- Update container tagging to use dynamic repo paths
- Pass build args for BASE_IMAGE and LS_REPO to Containerfile
- Enable flexible release downloads from forked repositories
Copy link
Copy Markdown

@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)
docker/llama-swap.Containerfile (1)

31-35: Optional: quote the full curl URL for readability and robustness.

Current command works, but quoting the entire URL is a bit clearer and future-proof against any odd characters:

-    curl -LO https://github.com/"${LS_REPO}"/releases/download/v"${LS_VER}"/llama-swap_"${LS_VER}"_linux_amd64.tar.gz && \
+    curl -LO "https://github.com/${LS_REPO}/releases/download/v${LS_VER}/llama-swap_${LS_VER}_linux_amd64.tar.gz" && \
📜 Review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 9f38155 and be71f3f.

📒 Files selected for processing (2)
  • docker/build-container.sh (3 hunks)
  • docker/llama-swap.Containerfile (2 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • docker/build-container.sh
🧰 Additional context used
🧠 Learnings (3)
📓 Common learnings
Learnt from: ryan-steed-usa
Repo: mostlygeek/llama-swap PR: 391
File: docker/build-container.sh:29-32
Timestamp: 2025-11-08T16:56:35.626Z
Learning: In the mostlygeek/llama-swap repository, llama.cpp container tags from ghcr.io/ggml-org/llama.cpp use build identifiers (e.g., `b6981`) rather than semantic versions. The tag format is `server-<something>-<build-id>` for cpu and `server-<arch>-<something>-<build-id>` for other architectures, where extracting the third field with `awk -F '-' '{print $3}'` correctly retrieves the build identifier.
Learnt from: ryan-steed-usa
Repo: mostlygeek/llama-swap PR: 368
File: docker/llama-swap.Containerfile:14-20
Timestamp: 2025-10-27T16:04:23.381Z
Learning: In docker/llama-swap.Containerfile, the user/group creation logic intentionally supports adding a non-root user (non-zero UID) to the root group (GID=0) as a valid configuration. This allows flexible UID/GID customization where users can specify only a UID or both UID and GID.
📚 Learning: 2025-10-27T16:04:23.381Z
Learnt from: ryan-steed-usa
Repo: mostlygeek/llama-swap PR: 368
File: docker/llama-swap.Containerfile:14-20
Timestamp: 2025-10-27T16:04:23.381Z
Learning: In docker/llama-swap.Containerfile, the user/group creation logic intentionally supports adding a non-root user (non-zero UID) to the root group (GID=0) as a valid configuration. This allows flexible UID/GID customization where users can specify only a UID or both UID and GID.

Applied to files:

  • docker/llama-swap.Containerfile
📚 Learning: 2025-11-08T16:56:35.626Z
Learnt from: ryan-steed-usa
Repo: mostlygeek/llama-swap PR: 391
File: docker/build-container.sh:29-32
Timestamp: 2025-11-08T16:56:35.626Z
Learning: In the mostlygeek/llama-swap repository, llama.cpp container tags from ghcr.io/ggml-org/llama.cpp use build identifiers (e.g., `b6981`) rather than semantic versions. The tag format is `server-<something>-<build-id>` for cpu and `server-<arch>-<something>-<build-id>` for other architectures, where extracting the third field with `awk -F '-' '{print $3}'` correctly retrieves the build identifier.

Applied to files:

  • docker/llama-swap.Containerfile
🔇 Additional comments (1)
docker/llama-swap.Containerfile (1)

1-7: Configurable base image and repo args look correct and backward-compatible.

Using ARG BASE_IMAGE/BASE_TAG in FROM and ARG LS_REPO=mostlygeek/llama-swap preserves prior defaults while allowing forks and alternate base images via build-args. No issues spotted here.

@ryan-steed-usa ryan-steed-usa changed the title Flexible container build feat: Add support for custom llama.cpp base image and forked llama-swap repositories Nov 29, 2025
@mostlygeek
Copy link
Copy Markdown
Owner

LGTM

@mostlygeek mostlygeek merged commit a883d68 into mostlygeek:main Nov 30, 2025
3 checks passed
@ryan-steed-usa ryan-steed-usa deleted the flexible-container-build branch November 30, 2025 05:52
rohitpaul pushed a commit to rohitpaul/llama-swap that referenced this pull request Mar 29, 2026
…ap repositories (mostlygeek#396)

* feat: Add support for custom llama.cpp base image and forked llama-swap repositories

- Introduce BASE_LLAMACPP_IMAGE env var to customize llama.cpp base image
- Introduce LS_REPO env var to customize llama-swap source
- Use GITHUB_REPOSITORY env var to automatically detect forked repos
- Update container tagging to use dynamic repo paths
- Pass build args for BASE_IMAGE and LS_REPO to Containerfile
- Enable flexible release downloads from forked repositories

* chore: quote entire curl options, appease coderabbitai
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