├── .gitattributes
├── bin
└── bfg-1.14.0.jar
├── Dockerfile
├── .github
├── dependabot.yml
└── workflows
│ ├── dive-check.yml
│ └── docker-publish.yml
├── .dive-ci.yml
├── LICENSE
└── README.md
/.gitattributes:
--------------------------------------------------------------------------------
1 | *.jar filter=lfs diff=lfs merge=lfs -text
2 |
--------------------------------------------------------------------------------
/bin/bfg-1.14.0.jar:
--------------------------------------------------------------------------------
1 | version https://git-lfs.github.com/spec/v1
2 | oid sha256:1a75e9390541f4b55d9c01256b361b815c1e0a263e2fb3d072b55c2911ead0b7
3 | size 14483456
4 |
--------------------------------------------------------------------------------
/Dockerfile:
--------------------------------------------------------------------------------
1 | FROM openjdk:8-jre-slim
2 | COPY bin/bfg-1.14.0.jar bfg.jar
3 | RUN echo "#!/usr/local/openjdk-8/bin/java -jar" > bfg && \
4 | cat bfg.jar >> bfg && \
5 | mv bfg /bin && \
6 | chmod +x /bin/bfg && \
7 | rm bfg.jar
--------------------------------------------------------------------------------
/.github/dependabot.yml:
--------------------------------------------------------------------------------
1 | version: 2
2 | updates:
3 | - package-ecosystem: "docker"
4 | directory: "/"
5 | schedule:
6 | interval: "weekly"
7 | - package-ecosystem: "github-actions"
8 | directory: "/"
9 | schedule:
10 | interval: "weekly"
11 |
--------------------------------------------------------------------------------
/.dive-ci.yml:
--------------------------------------------------------------------------------
1 | rules:
2 | # If the efficiency is measured below X%, mark as failed.
3 | # Expressed as a ratio between 0-1.
4 | lowestEfficiency: 0.98
5 |
6 | # If the amount of wasted space is at least X or larger than X, mark as failed.
7 | # Expressed in B, KB, MB, and GB.
8 | highestWastedBytes: 5MB
9 |
10 | # If the amount of wasted space makes up for X% or more of the image, mark as failed.
11 | # Note: the base image layer is NOT included in the total image size.
12 | # Expressed as a ratio between 0-1; fails if the threshold is met or crossed.
13 | highestUserWastedPercent: 0.10
14 |
--------------------------------------------------------------------------------
/.github/workflows/dive-check.yml:
--------------------------------------------------------------------------------
1 | name: CI Dive Check
2 | on:
3 | push:
4 | branches: [ main ]
5 | pull_request:
6 | branches: [ main ]
7 | workflow_dispatch:
8 |
9 | jobs:
10 | check:
11 | runs-on: ubuntu-latest
12 |
13 | steps:
14 | - uses: actions/checkout@v4
15 |
16 | - name: Build image
17 | run: docker build -t bfg-repo-cleaner:temp .
18 | - name: Dive
19 | run: docker run -e CI=true -e DOCKER_API_VERSION=1.37 --rm -v /var/run/docker.sock:/var/run/docker.sock --mount type=bind,source=/home/runner/work/docker-bfg-repo-cleaner/docker-bfg-repo-cleaner/.dive-ci.yml,target=/.dive-ci wagoodman/dive:latest bfg-repo-cleaner:temp --ci-config /.dive-ci
20 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2022 Raul Piraces Alastuey
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/.github/workflows/docker-publish.yml:
--------------------------------------------------------------------------------
1 | name: Publish Docker image
2 |
3 | on:
4 | release:
5 | types: [published]
6 | workflow_dispatch:
7 |
8 | jobs:
9 | push_to_registries:
10 | name: Push Docker image to multiple registries
11 | runs-on: ubuntu-latest
12 | permissions:
13 | packages: write
14 | contents: read
15 | steps:
16 | - name: Check out the repo
17 | uses: actions/checkout@v4
18 |
19 | - name: Log in to Docker Hub
20 | uses: docker/login-action@v3
21 | with:
22 | username: ${{ secrets.DOCKER_USERNAME }}
23 | password: ${{ secrets.DOCKER_PASSWORD }}
24 |
25 | - name: Log in to the Container registry
26 | uses: docker/login-action@v3
27 | with:
28 | registry: ghcr.io
29 | username: ${{ github.actor }}
30 | password: ${{ secrets.GITHUB_TOKEN }}
31 |
32 | - name: Extract metadata (tags, labels) for Docker
33 | id: meta
34 | uses: docker/metadata-action@v5
35 | with:
36 | images: |
37 | piraces/bfg-repo-cleaner
38 | ghcr.io/piraces/bfg-repo-cleaner
39 |
40 | - name: Build and push Docker images
41 | uses: docker/build-push-action@v6
42 | with:
43 | context: .
44 | push: true
45 | tags: ${{ steps.meta.outputs.tags }}
46 | labels: ${{ steps.meta.outputs.labels }}
47 |
48 | - name: Upload artifact
49 | uses: actions/upload-artifact@v4
50 | with:
51 | name: bfg-repo-cleaner-docker-file
52 | path: Dockerfile
53 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # docker-bfg-repo-cleaner
2 |
3 | [](https://github.com/piraces/docker-bfg-repo-cleaner/actions/workflows/docker-publish.yml)
4 | [](https://github.com/piraces/docker-bfg-repo-cleaner/actions/workflows/dive-check.yml)
5 |
6 |
7 |
8 |
9 | A docker image for [BFG Repo-Cleaner (by rtyley)](https://rtyley.github.io/bfg-repo-cleaner/).
10 |
11 | # How is built
12 |
13 | - Actually is built using the [openjdk](https://hub.docker.com/_/openjdk/) official image only with JRE ([openjdk:8-jre-slim](https://hub.docker.com/_/openjdk/?tab=tags&page=1&name=8-jre-slim)).
14 | - The actual `.jar` file is in this repo, managed with `Git LFS`. You can check the checksum from the original published `.jar` [available here](https://repo1.maven.org/maven2/com/madgag/bfg/1.14.0/bfg-1.14.0.jar).
15 | - In order to be able to execute the command `bfg` as it is, a little trick is made by specifying a ['Shebang'](https://bash.cyberciti.biz/guide/Shebang) and the `.jar` file content in an executable in the `/bin` folder of the container.
16 |
17 | # How to use it
18 |
19 | It only requires you to mount the repository you want to use with `bfg` and perform the command you want.
20 |
21 | For example to remove `.env` files in my repository using `bfg`:
22 |
23 | ```bash
24 | docker run --rm -v /c/DEV:/usr/src/myrepo -w /usr/src/myrepo piraces/bfg-repo-cleaner:latest bfg --delete-files .env /usr/src/myrepo/exercise-remove-commit-history.git # Using Docker Hub image
25 |
26 | docker run --rm -v /c/DEV:/usr/src/myrepo -w /usr/src/myrepo ghcr.io/piraces/bfg-repo-cleaner:latest bfg --delete-files .env /usr/src/myrepo/exercise-remove-commit-history.git # Using GitHub Docker image (no pull limits)
27 | ```
28 |
29 | Make sure to specify the correct path to mount and the working directory.
30 |
31 | # CI/CD workflows
32 |
33 | There are two workflows defined in this repository:
34 | - [Publish Docker Image](https://github.com/piraces/docker-bfg-repo-cleaner/actions/workflows/docker-publish.yml): builds, tag, label and push the image on every release to GitHub Docker repository and Docker Hub.
35 | - [CI Dive Check](https://github.com/piraces/docker-bfg-repo-cleaner/actions/workflows/dive-check.yml): checks with [dive](https://github.com/wagoodman/dive) every commit and PR to ensure we are keeping wasted space to a minimum.
36 |
--------------------------------------------------------------------------------