From 2a0c08343329b6d12bfe523f31d02868f0d5565b Mon Sep 17 00:00:00 2001 From: Juan Calderon-Perez <835733+gaby@users.noreply.github.com> Date: Sat, 28 Dec 2024 13:30:56 -0500 Subject: [PATCH 01/12] Add support for Docker --- .github/workflows/docker.yml | 62 ++++++++++++++++++++++++++++++++++++ Dockerfile | 10 ++++++ README.md | 8 +++++ 3 files changed, 80 insertions(+) create mode 100644 .github/workflows/docker.yml create mode 100644 Dockerfile diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml new file mode 100644 index 0000000..e2c4569 --- /dev/null +++ b/.github/workflows/docker.yml @@ -0,0 +1,62 @@ +name: Docker + +on: + push: + branches: + - "main" + paths-ignore: + - "**.md" + - LICENSE + pull_request: + branches: + - "*" + paths: + - "Dockerfile" + workflow_dispatch: + release: + types: [published, edited] + +jobs: + build-and-publish-image: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v4 + - name: Docker metadata + id: meta + uses: docker/metadata-action@v5 + 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}} + + - name: Set up QEMU + uses: docker/setup-qemu-action@v3 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + + - name: Login to GitHub Container Registry + if: github.event_name != 'pull_request' + uses: docker/login-action@v3 + with: + registry: ghcr.io + username: ${{ github.repository_owner }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Build and Publish Docker Image + uses: docker/build-push-action@v6 + with: + context: . + push: ${{ github.event_name != 'pull_request' }} + target: release + cache-from: type=gha + cache-to: type=gha,mode=max + platforms: linux/amd64 + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} \ No newline at end of file diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..37bbc24 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,10 @@ +FROM node:22-slim + +RUN apt-get update && apt-get install -y --no-install-recommends \ + git ca-certificates \ + && rm -rf /var/lib/apt/lists/* \ + && npm install -g repomix + +WORKDIR /app + +ENTRYPOINT ["repomix"] \ No newline at end of file diff --git a/README.md b/README.md index 17c43fe..d117793 100644 --- a/README.md +++ b/README.md @@ -95,6 +95,14 @@ To initialize a new configuration file (`repomix.config.json`): repomix --init ``` +### 🐳 Docker + +Run Repomix using Docker + +```bash +docker run -v ./output:/app -it --rm ghcr.io/yamadashy/repomix --remote https://github.com/yamadashy/repomix +``` + Once you have generated the packed file, you can use it with Generative AI tools like Claude, ChatGPT, and Gemini. ### Prompt Examples From 136292fd360d79311aa35c0ef350e1e5dca735c0 Mon Sep 17 00:00:00 2001 From: Juan Calderon-Perez <835733+gaby@users.noreply.github.com> Date: Sat, 28 Dec 2024 13:47:29 -0500 Subject: [PATCH 02/12] Update Dockerfile --- Dockerfile | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Dockerfile b/Dockerfile index 37bbc24..76b64bb 100644 --- a/Dockerfile +++ b/Dockerfile @@ -3,8 +3,9 @@ FROM node:22-slim RUN apt-get update && apt-get install -y --no-install-recommends \ git ca-certificates \ && rm -rf /var/lib/apt/lists/* \ - && npm install -g repomix + && npm install -g repomix --no-cache-dir \ + && npm cache clean --force WORKDIR /app -ENTRYPOINT ["repomix"] \ No newline at end of file +ENTRYPOINT ["repomix"] From fda9c5f210219bc8951fb0f9ec9097a1ac49d51c Mon Sep 17 00:00:00 2001 From: Juan Calderon-Perez <835733+gaby@users.noreply.github.com> Date: Sat, 28 Dec 2024 16:25:25 -0500 Subject: [PATCH 03/12] Update Dockerfile --- Dockerfile | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/Dockerfile b/Dockerfile index 76b64bb..a39b4e6 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,11 +1,18 @@ FROM node:22-slim RUN apt-get update && apt-get install -y --no-install-recommends \ - git ca-certificates \ - && rm -rf /var/lib/apt/lists/* \ - && npm install -g repomix --no-cache-dir \ - && npm cache clean --force + git \ + ca-certificates \ + && rm -rf /var/lib/apt/lists/* WORKDIR /app -ENTRYPOINT ["repomix"] +COPY package*.json ./ + +RUN npm install + +COPY . . + +RUN npm run build + +ENTRYPOINT ["npx", "repomix"] From d377ec51844912420f2cbdfab917c6851d802803 Mon Sep 17 00:00:00 2001 From: Juan Calderon-Perez <835733+gaby@users.noreply.github.com> Date: Sat, 28 Dec 2024 16:28:08 -0500 Subject: [PATCH 04/12] Add .dockerignore --- .dockerignore | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 .dockerignore diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..7d366ee --- /dev/null +++ b/.dockerignore @@ -0,0 +1,12 @@ +node_modules +npm-debug.log +.git +.gitignore +.env +.env.* +*.md +.vscode +coverage +.nyc_output +dist +build \ No newline at end of file From aec6533179f3423ee8802fc1b8df0297734a3488 Mon Sep 17 00:00:00 2001 From: Juan Calderon-Perez <835733+gaby@users.noreply.github.com> Date: Sat, 28 Dec 2024 23:31:03 -0500 Subject: [PATCH 05/12] Remove target tag from Docker build --- .github/workflows/docker.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml index e2c4569..982dca7 100644 --- a/.github/workflows/docker.yml +++ b/.github/workflows/docker.yml @@ -54,9 +54,8 @@ jobs: with: context: . push: ${{ github.event_name != 'pull_request' }} - target: release cache-from: type=gha cache-to: type=gha,mode=max platforms: linux/amd64 tags: ${{ steps.meta.outputs.tags }} - labels: ${{ steps.meta.outputs.labels }} \ No newline at end of file + labels: ${{ steps.meta.outputs.labels }} From 2c7f84d3ed4b5bda11b82fa3d793e0b7a24b49c8 Mon Sep 17 00:00:00 2001 From: Kazuki Yamada Date: Sun, 29 Dec 2024 17:58:49 +0900 Subject: [PATCH 06/12] feat(docker): Provide repomix as a globally available tool in the Docker image --- .github/workflows/docker.yml | 2 ++ Dockerfile | 13 +++++++++---- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml index 982dca7..27e15c4 100644 --- a/.github/workflows/docker.yml +++ b/.github/workflows/docker.yml @@ -12,6 +12,8 @@ on: - "*" paths: - "Dockerfile" + - ".dockerignore" + - ".github/workflows/docker.yml" workflow_dispatch: release: types: [published, edited] diff --git a/Dockerfile b/Dockerfile index a39b4e6..17d16cf 100644 --- a/Dockerfile +++ b/Dockerfile @@ -5,14 +5,19 @@ RUN apt-get update && apt-get install -y --no-install-recommends \ ca-certificates \ && rm -rf /var/lib/apt/lists/* -WORKDIR /app +RUN mkdir /repomix +WORKDIR /repomix +# Install dependencies COPY package*.json ./ - RUN npm install +# Build and link repomix COPY . . +RUN npm install \ + && npm run build \ + && npm link -RUN npm run build +WORKDIR /app -ENTRYPOINT ["npx", "repomix"] +ENTRYPOINT ["repomix"] From 4bf46e8ca0ff1b1de986060f7fae9487525658cb Mon Sep 17 00:00:00 2001 From: Kazuki Yamada Date: Sun, 29 Dec 2024 18:02:58 +0900 Subject: [PATCH 07/12] docs(docker): Docker usage instructions to CONTRIBUTING.md and README.md --- CONTRIBUTING.md | 13 +++++++++++++ README.md | 8 +++++--- 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index b1ba21f..b45538c 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -38,6 +38,19 @@ To run Repomix locally: npm run cli-run ``` +### 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: +```bash +docker run -v ./:/app -it --rm repomix +``` + ### Coding Style We use [Biome](https://biomejs.dev/) for linting and formatting. Please make sure your code follows the style guide by running: diff --git a/README.md b/README.md index d117793..416bfd0 100644 --- a/README.md +++ b/README.md @@ -95,11 +95,13 @@ To initialize a new configuration file (`repomix.config.json`): repomix --init ``` -### 🐳 Docker - -Run Repomix using Docker +You can run it using Docker 🐳 ```bash +# Basic usage (current directory) +docker run -v .:/app -it --rm ghcr.io/yamadashy/repomix + +# Process a remote repository and output to a `output` directory docker run -v ./output:/app -it --rm ghcr.io/yamadashy/repomix --remote https://github.com/yamadashy/repomix ``` From fc2f6ae7cc494f626ae8c613655dbb1342fcd459 Mon Sep 17 00:00:00 2001 From: Kazuki Yamada Date: Sun, 29 Dec 2024 18:07:19 +0900 Subject: [PATCH 08/12] docs(docker): Enhance README.md Docker documentation --- README.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 416bfd0..fc268fd 100644 --- a/README.md +++ b/README.md @@ -95,7 +95,9 @@ To initialize a new configuration file (`repomix.config.json`): repomix --init ``` -You can run it using Docker 🐳 +### Docker Usage +You can also run Repomix using Docker 🐳 +This is useful if you want to run Repomix in an isolated environment or prefer using containers. ```bash # Basic usage (current directory) From bae5f4b078eca613cd5b10f50d942402b5515760 Mon Sep 17 00:00:00 2001 From: Kazuki Yamada Date: Sun, 29 Dec 2024 18:08:40 +0900 Subject: [PATCH 09/12] docs(docker): Move packed file usage explanation in README.md --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index fc268fd..25291a5 100644 --- a/README.md +++ b/README.md @@ -95,6 +95,8 @@ To initialize a new configuration file (`repomix.config.json`): repomix --init ``` +Once you have generated the packed file, you can use it with Generative AI tools like Claude, ChatGPT, and Gemini. + ### Docker Usage You can also run Repomix using Docker 🐳 This is useful if you want to run Repomix in an isolated environment or prefer using containers. @@ -107,8 +109,6 @@ docker run -v .:/app -it --rm ghcr.io/yamadashy/repomix docker run -v ./output:/app -it --rm ghcr.io/yamadashy/repomix --remote https://github.com/yamadashy/repomix ``` -Once you have generated the packed file, you can use it with Generative AI tools like Claude, ChatGPT, and Gemini. - ### Prompt Examples Once you have generated the packed file with Repomix, you can use it with AI tools like Claude, ChatGPT, and Gemini. Here are some example prompts to get you started: From dbaa95bb39ae4885b9c553adaa2e27c8120cea59 Mon Sep 17 00:00:00 2001 From: Kazuki Yamada Date: Sun, 29 Dec 2024 19:03:04 +0900 Subject: [PATCH 10/12] feat(docker): Optimize Docker image size by streamlining npm commands --- Dockerfile | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/Dockerfile b/Dockerfile index 17d16cf..577f771 100644 --- a/Dockerfile +++ b/Dockerfile @@ -8,15 +8,13 @@ RUN apt-get update && apt-get install -y --no-install-recommends \ RUN mkdir /repomix WORKDIR /repomix -# Install dependencies -COPY package*.json ./ -RUN npm install - -# Build and link repomix +# Install dependencies and build repomix, then link the package to the global scope COPY . . -RUN npm install \ +RUN npm ci \ && npm run build \ - && npm link + && npm link \ + && npm ci --omit=dev \ + && npm cache clean --force WORKDIR /app From 17d869bb71d9bf593a428da6fafc9a982be2e139 Mon Sep 17 00:00:00 2001 From: Juan Calderon-Perez <835733+gaby@users.noreply.github.com> Date: Sun, 29 Dec 2024 12:04:44 -0500 Subject: [PATCH 11/12] Make sure help menu shows up during build --- Dockerfile | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 577f771..5735b49 100644 --- a/Dockerfile +++ b/Dockerfile @@ -14,7 +14,8 @@ RUN npm ci \ && npm run build \ && npm link \ && npm ci --omit=dev \ - && npm cache clean --force + && npm cache clean --force \ + && repomix --help WORKDIR /app From 071bae06fb057194b38f6b3518ac3413134149ae Mon Sep 17 00:00:00 2001 From: Kazuki Yamada Date: Mon, 30 Dec 2024 12:42:59 +0900 Subject: [PATCH 12/12] feat(docker): Separate RUN commands --- Dockerfile | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/Dockerfile b/Dockerfile index 5735b49..0a59176 100644 --- a/Dockerfile +++ b/Dockerfile @@ -9,14 +9,18 @@ RUN mkdir /repomix WORKDIR /repomix # Install dependencies and build repomix, then link the package to the global scope +# To reduce the size of the layer, npm ci and npm link are executed in the same RUN command COPY . . RUN npm ci \ && npm run build \ && npm link \ && npm ci --omit=dev \ - && npm cache clean --force \ - && repomix --help + && npm cache clean --force WORKDIR /app +# Check the operation of repomix +RUN repomix --version +RUN repomix --help + ENTRYPOINT ["repomix"]