-
-
Notifications
You must be signed in to change notification settings - Fork 377
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 support for Docker #222
Conversation
Run & review this pull request in StackBlitz Codeflow. |
📝 WalkthroughWalkthroughThis pull request introduces Docker support for Repomix by adding a new GitHub Actions workflow for building and publishing Docker images, creating a Dockerfile, and updating the README with Docker usage instructions. The workflow automates the process of building multi-platform Docker images for the project, enabling users to run Repomix in a containerized environment. Changes
Assessment against linked issues
Possibly related PRs
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? 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
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)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this 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
🧹 Nitpick comments (3)
.github/workflows/docker.yml (2)
60-60
: Enhance multi-platform supportCurrently, the image is only built for
linux/amd64
. Consider adding support for ARM architectures to improve compatibility.- platforms: linux/amd64 + platforms: linux/amd64,linux/arm64
7-8
: Consider adding more specific path filtersThe current path filters might miss important Docker-related changes. Consider adding more specific paths:
paths-ignore: - "**.md" - LICENSE + - "docs/**" + - "*.txt" paths: - "Dockerfile" + - ".github/workflows/docker.yml" + - "docker/**"Also applies to: 14-14
README.md (1)
98-104
: Enhance Docker documentationThe current Docker documentation could be more comprehensive. Consider adding:
- Explanation of the volume mount (
-v ./output:/app
)- Environment variables documentation
- More usage examples
- Troubleshooting section
Example additions:
### 🐳 Docker Run Repomix using Docker: ```bash # Basic usage docker run -v ./output:/app -it --rm ghcr.io/yamadashy/repomix --remote https://github.com/yamadashy/repomix # With custom configuration docker run -v ./output:/app -v ./repomix.config.json:/app/repomix.config.json -it --rm ghcr.io/yamadashy/repomix # Process local directory docker run -v ./my-project:/app/src -v ./output:/app/output -it --rm ghcr.io/yamadashy/repomix ./srcVolume Mounts
-v ./output:/app
: Mounts the localoutput
directory to store the generated files-v ./repomix.config.json:/app/repomix.config.json
: (Optional) Mounts a custom configuration fileEnvironment Variables
REPOMIX_TOKEN
: GitHub token for accessing private repositoriesREPOMIX_CONFIG
: Path to custom configuration file inside the containerTroubleshooting
- Permission issues: If you encounter permission issues with the output directory, ensure it has the correct permissions:
chmod 777 ./output
- Network issues: When processing private repositories, ensure you've provided a valid GitHub token
</blockquote></details> </blockquote></details> <details> <summary>📜 Review details</summary> **Configuration used: CodeRabbit UI** **Review profile: CHILL** **Plan: Pro** <details> <summary>📥 Commits</summary> Reviewing files that changed from the base of the PR and between 28e3a76093093732022af039aeff7132b16dd4f3 and 05c73841e90f31306c0e8fc3b5e2a8485f9f3896. </details> <details> <summary>📒 Files selected for processing (3)</summary> * `.github/workflows/docker.yml` (1 hunks) * `Dockerfile` (1 hunks) * `README.md` (1 hunks) </details> <details> <summary>🧰 Additional context used</summary> <details> <summary>🪛 yamllint (1.35.1)</summary> <details> <summary>.github/workflows/docker.yml</summary> [error] 1-1: wrong new line character: expected \n (new-lines) --- [error] 62-62: no new line character at the end of file (new-line-at-end-of-file) </details> </details> </details> </details> <!-- This is an auto-generated comment by CodeRabbit for review status -->
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No issues flagged.
Standard Input can make mistakes. Check important info.
There was a problem hiding this 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 (2)
Dockerfile (2)
3-6
: Optimize apt-get commands for better cachingWhile the cleanup is good, we can further optimize the apt-get commands:
-RUN apt-get update && apt-get install -y --no-install-recommends \ +RUN apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \ git \ ca-certificates \ - && rm -rf /var/lib/apt/lists/* + && apt-get clean \ + && rm -rf /var/lib/apt/lists/*
18-18
: Consider direct binary execution instead of npxUsing
npx
in a container adds unnecessary overhead since we're installing the package globally:-ENTRYPOINT ["npx", "repomix"] +ENTRYPOINT ["repomix"]
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
Dockerfile
(1 hunks)
🔇 Additional comments (2)
Dockerfile (2)
8-8
: LGTM!
Setting the working directory to /app follows Docker best practices.
10-12
: 🛠️ Refactor suggestion
Optimize npm installation for production use
Consider these improvements for better security and smaller image size:
COPY package*.json ./
-RUN npm install
+RUN npm ci --only=production --no-audit \
+ && npm cache clean --force
This change:
- Uses
npm ci
for reproducible builds - Installs only production dependencies
- Cleans npm cache to reduce image size
Likely invalid or redundant comment.
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #222 +/- ##
=======================================
Coverage 92.01% 92.01%
=======================================
Files 44 44
Lines 2041 2041
Branches 450 450
=======================================
Hits 1878 1878
Misses 163 163 ☔ View full report in Codecov by Sentry. |
There was a problem hiding this 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
♻️ Duplicate comments (1)
.github/workflows/docker.yml (1)
52-61
: 🛠️ Refactor suggestionEnhance build security and compliance
As mentioned in the previous review, consider adding security enhancements. Additionally:
- name: Build and Publish Docker Image uses: docker/build-push-action@v6 with: context: . push: ${{ github.event_name != 'pull_request' }} cache-from: type=gha cache-to: type=gha,mode=max - platforms: linux/amd64 + platforms: linux/amd64,linux/arm64 tags: ${{ steps.meta.outputs.tags }} labels: ${{ steps.meta.outputs.labels }} + provenance: true + sbom: true + security-opt: seccomp=unconfined + no-cache: ${{ github.event_name == 'release' }}Also add a vulnerability scanning step before pushing:
- name: Run Trivy vulnerability scanner uses: aquasecurity/trivy-action@master if: github.event_name != 'pull_request' with: image-ref: ${{ steps.meta.outputs.tags }} format: 'sarif' output: 'trivy-results.sarif' severity: 'CRITICAL,HIGH' timeout: '10m'
🧹 Nitpick comments (5)
.github/workflows/docker.yml (5)
3-17
: Enhance trigger paths for better coverageConsider expanding the trigger paths to ensure all Docker-related changes are captured:
push: branches: - "main" paths-ignore: - "**.md" - LICENSE + - ".gitignore" pull_request: branches: - "*" paths: - "Dockerfile" + - ".dockerignore" + - ".github/workflows/docker.yml" + - "docker-compose*.yml"
25-37
: Add OCI image metadata labelsConsider adding standard OCI labels to improve image discoverability and documentation:
- name: Docker metadata id: meta uses: docker/metadata-action@v5 with: images: | ghcr.io/yamadashy/repomix + labels: | + org.opencontainers.image.title=Repomix + org.opencontainers.image.description=A tool for mixing repository files + org.opencontainers.image.source={{repo}} + org.opencontainers.image.licenses=MIT tags: | type=ref,event=branch type=ref,event=pr type=semver,pattern={{version}} type=semver,pattern={{major}} type=semver,pattern={{major}}.{{minor}}
38-43
: Consider supporting additional platformsThe QEMU setup enables multi-platform builds, but the workflow only builds for
linux/amd64
. Consider adding support for ARM platforms:- name: Set up QEMU uses: docker/setup-qemu-action@v3 + with: + platforms: linux/amd64,linux/arm64
44-51
: Declare required token permissionsWhile the authentication setup is secure, it's recommended to explicitly declare the required token permissions:
Add this at the top of the workflow:
permissions: contents: read packages: write
1-61
: Fix line endingsThe file has incorrect line endings. Ensure consistent Unix-style line endings (\n) throughout the file.
Add a
.gitattributes
file to enforce consistent line endings:+*.yml text eol=lf +*.yaml text eol=lf🧰 Tools
🪛 yamllint (1.35.1)
[error] 1-1: wrong new line character: expected \n
(new-lines)
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
.github/workflows/docker.yml
(1 hunks)
🧰 Additional context used
🪛 yamllint (1.35.1)
.github/workflows/docker.yml
[error] 1-1: wrong new line character: expected \n
(new-lines)
🔇 Additional comments (1)
.github/workflows/docker.yml (1)
19-24
: LGTM!
The job setup is well-configured with the latest Ubuntu runner and checkout action.
I can probably add a stage that runs the image in the workflow to make sure it's working before pushing it to ghcr.io |
There was a problem hiding this 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 (2)
Dockerfile (1)
8-9
: Consider using multi-stage build for better separation of concernsWhile creating a dedicated directory is good, consider using a multi-stage build to separate build environment from runtime environment.
-RUN mkdir /repomix -WORKDIR /repomix +# Build stage +FROM node:22-slim AS builder +WORKDIR /build +# Runtime stage +FROM node:22-slim +WORKDIR /app.github/workflows/docker.yml (1)
27-39
: Enhance Docker image metadataConsider adding:
- The
latest
tag for the main branch- Description and other OCI labels
with: images: | ghcr.io/yamadashy/repomix tags: | type=ref,event=branch type=ref,event=pr type=semver,pattern={{version}} type=semver,pattern={{major}} type=semver,pattern={{major}}.{{minor}} + type=raw,value=latest,enable={{is_default_branch}} + labels: | + org.opencontainers.image.title=Repomix + org.opencontainers.image.description=CLI tool for repository management
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (2)
.github/workflows/docker.yml
(1 hunks)Dockerfile
(1 hunks)
🧰 Additional context used
🪛 yamllint (1.35.1)
.github/workflows/docker.yml
[error] 1-1: wrong new line character: expected \n
(new-lines)
🔇 Additional comments (6)
Dockerfile (3)
1-6
: LGTM! Base image setup follows best practices
The setup uses appropriate base image and follows Docker best practices:
- Uses slim variant for smaller image size
- Properly installs only required packages
- Cleans up apt lists to reduce image size
21-23
: LGTM! Runtime configuration is properly set
The working directory and entrypoint configuration are appropriate for running the CLI tool.
15-19
: 🛠️ Refactor suggestion
Optimize build process and ensure proper file exclusions
- The build process could be optimized:
-RUN npm install \
- && npm run build \
- && npm link
+RUN npm run build && npm link
- Ensure you have a
.dockerignore
file to exclude unnecessary files (node_modules, .git, etc.) from the build context.
.github/workflows/docker.yml (3)
1-20
: LGTM! Workflow triggers are well configured
The workflow triggers are comprehensive and include appropriate path filters to avoid unnecessary builds.
🧰 Tools
🪛 yamllint (1.35.1)
[error] 1-1: wrong new line character: expected \n
(new-lines)
46-53
: LGTM! Authentication is properly configured
The GitHub Container Registry authentication is correctly set up using the built-in GITHUB_TOKEN.
54-63
: 🛠️ Refactor suggestion
Enhance build security and platform support
Consider these improvements:
- Enable security features
- Add multi-platform support
with:
context: .
push: ${{ github.event_name != 'pull_request' }}
cache-from: type=gha
cache-to: type=gha,mode=max
- platforms: linux/amd64
+ platforms: linux/amd64,linux/arm64
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
+ provenance: true
+ sbom: true
Likely invalid or redundant comment.
There was a problem hiding this 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)
CONTRIBUTING.md (1)
44-52
: Enhance Docker usage documentation with more details and examples.While the basic Docker commands are correct, the documentation could be more helpful for new users by:
- Explaining the volume mount:
Then, run the Docker container: ```bash # Mount current directory to /app in container for processing local files docker run -v ./:/app -it --rm repomix2. Adding examples for specific commands: ```markdown ### Examples Run with specific options: ```bash docker run -v ./:/app -it --rm repomix --input ./input --output ./output
Run with environment variables:
docker run -v ./:/app -e NODE_ENV=production -it --rm repomixWould you like me to provide a complete documentation update with these enhancements? </blockquote></details> </blockquote></details> <details> <summary>📜 Review details</summary> **Configuration used: CodeRabbit UI** **Review profile: CHILL** **Plan: Pro** <details> <summary>📥 Commits</summary> Reviewing files that changed from the base of the PR and between 632f560c3dbbc3ecfd270b175791bf97cdac5122 and 99cc38e853fc5283e622009df04ed6b5aed6c5ed. </details> <details> <summary>📒 Files selected for processing (2)</summary> * `CONTRIBUTING.md` (1 hunks) * `README.md` (1 hunks) </details> <details> <summary>🚧 Files skipped from review as they are similar to previous changes (1)</summary> * README.md </details> <details> <summary>🔇 Additional comments (1)</summary> <details> <summary>CONTRIBUTING.md (1)</summary> `41-42`: **LGTM! Clear section introduction.** The new Docker Usage section is well-placed and clearly introduced. </details> </details> </details> <!-- This is an auto-generated comment by CodeRabbit for review status -->
There was a problem hiding this 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)
Dockerfile (1)
8-9
: Consider simplifying the directory structure.The intermediate
/repomix
directory might be unnecessary since you later switch to/app
. Consider consolidating the build process in a single directory.-RUN mkdir /repomix -WORKDIR /repomix +WORKDIR /app
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (2)
Dockerfile
(1 hunks)README.md
(1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
- README.md
🔇 Additional comments (2)
Dockerfile (2)
1-6
: LGTM! Base image and system dependencies are well configured.
The use of node:22-slim
has been previously discussed and confirmed. The minimal system dependencies and cleanup of apt lists follow Docker best practices.
19-21
: LGTM! Final configuration is appropriate for a CLI tool.
The working directory and entrypoint configuration are well-suited for running repomix as a CLI tool in a container.
Hi, @gaby ! I've made a few adjustments, including tweaking the README and optimizing the image size.
That's a great idea! I'd really appreciate it if you could add a stage to the workflow to test the image before pushing it to ghcr.io. That would be a huge help in ensuring the quality of the image. |
@yamadashy Instead of adding another stage. I'm running See output here: https://github.com/gaby/repomix/actions/runs/12537229763/job/34961107768?pr=1 |
There was a problem hiding this 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 (2)
.github/workflows/docker.yml (1)
40-45
: Consider expanding platform supportQEMU is set up for multi-platform builds, but the build step only targets
linux/amd64
. Consider adding support for more platforms likelinux/arm64
to improve compatibility.- platforms: linux/amd64 + platforms: linux/amd64,linux/arm64Also applies to: 61-61
CONTRIBUTING.md (1)
41-52
: Enhance Docker usage documentationThe Docker usage instructions could be improved with:
- Clarification about the volume mount path
- Additional development-specific commands
Consider expanding the documentation:
### Docker Usage You can also run Repomix using Docker. Here's how: First, build the Docker image: ```bash docker build -t repomix .Then, run the Docker container:
docker run -v ./:/app -it --rm repomix
+For development, you can run tests in Docker:
+bash +docker run -v ./:/app -it --rm repomix npm run test +
+
+Note: The-v ./:/app
flag mounts your current directory to/app
in the container,
+allowing you to edit files locally while running them in the container.</blockquote></details> </blockquote></details> <details> <summary>📜 Review details</summary> **Configuration used: CodeRabbit UI** **Review profile: CHILL** **Plan: Pro** <details> <summary>📥 Commits</summary> Reviewing files that changed from the base of the PR and between d4052935ffea650cc99c6bd091da3e971b82f12b and 071bae06fb057194b38f6b3518ac3413134149ae. </details> <details> <summary>📒 Files selected for processing (5)</summary> * `.dockerignore` (1 hunks) * `.github/workflows/docker.yml` (1 hunks) * `CONTRIBUTING.md` (1 hunks) * `Dockerfile` (1 hunks) * `README.md` (1 hunks) </details> <details> <summary>🚧 Files skipped from review as they are similar to previous changes (3)</summary> * README.md * Dockerfile * .dockerignore </details> <details> <summary>🧰 Additional context used</summary> <details> <summary>🪛 yamllint (1.35.1)</summary> <details> <summary>.github/workflows/docker.yml</summary> [error] 1-1: wrong new line character: expected \n (new-lines) </details> </details> </details> <details> <summary>🔇 Additional comments (3)</summary> <details> <summary>.github/workflows/docker.yml (3)</summary> `3-20`: **LGTM! Well-structured workflow triggers.** The workflow triggers are appropriately configured to: - Build on main branch pushes while ignoring documentation changes - Respond to PRs affecting Docker-related files - Support manual triggering and release events --- `27-39`: **Improve build security and compliance** Consider adding security enhancements like provenance attestation and SBOM generation. --- `46-53`: **LGTM! Secure registry authentication.** The registry login is properly configured with: - Conditional execution skipping PRs - Secure token usage </details> </details> </details> <!-- This is an auto-generated comment by CodeRabbit for review status -->
@gaby I'll proceed with merging this PR. If any additional adjustments are needed, I might reach out to you again, and I appreciate your help in advance. Thanks again for your work on this! |
@yamadashy Sounds good to me, once merge the |
@yamadashy Add this to the workflow between line 19-21: permissions:
contents: read
packages: write |
@gaby |
I see the image was posted! https://github.com/yamadashy/repomix/pkgs/container/repomix |
New workflow worked, image was also pushed. |
I'll try releasing a version now. |
Dockerfile
to facilitate runningrepomix
using Docker.README
with instructions on how to run the cli using Docker.main
, and when a release is tagged.ghcr.io/yamadashy/repomix:main
tagsemver
tags for the Docker image.Fixes #221
@yamadashy You may have to tweak
Package Settings
to make the image public. https://docs.github.com/en/packages/learn-github-packages/configuring-a-packages-access-control-and-visibilityAs a separate PR, we could make this repo a
Github Action
that people can run on their repos to automatically generate the output usingrepomix
.