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 diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml new file mode 100644 index 0000000..27e15c4 --- /dev/null +++ b/.github/workflows/docker.yml @@ -0,0 +1,63 @@ +name: Docker + +on: + push: + branches: + - "main" + paths-ignore: + - "**.md" + - LICENSE + pull_request: + branches: + - "*" + paths: + - "Dockerfile" + - ".dockerignore" + - ".github/workflows/docker.yml" + 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' }} + cache-from: type=gha + cache-to: type=gha,mode=max + platforms: linux/amd64 + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} 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/Dockerfile b/Dockerfile new file mode 100644 index 0000000..0a59176 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,26 @@ +FROM node:22-slim + +RUN apt-get update && apt-get install -y --no-install-recommends \ + git \ + ca-certificates \ + && rm -rf /var/lib/apt/lists/* + +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 + +WORKDIR /app + +# Check the operation of repomix +RUN repomix --version +RUN repomix --help + +ENTRYPOINT ["repomix"] diff --git a/README.md b/README.md index 17c43fe..25291a5 100644 --- a/README.md +++ b/README.md @@ -97,6 +97,18 @@ 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. + +```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 +``` + ### 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: