From 9fceccc0b20550b4186e3555a036444ce2e21959 Mon Sep 17 00:00:00 2001 From: Paul Campbell Date: Fri, 27 Dec 2024 14:02:39 +0000 Subject: [PATCH] chore: simplify docker image generation Remove the use of a separate builder image --- .dockerignore | 1 + .forgejo/workflows/push-main.yml | 20 ++++++++++++++++++++ .forgejo/workflows/push-next.yml | 24 ++++++++++++++++++++++++ .woodpecker/cron-docker-builder.yml | 15 --------------- .woodpecker/push-next.yml | 13 ------------- .woodpecker/tag-created.yml | 16 ---------------- Dockerfile | 12 +++++++++++- Dockerfile.builder | 21 --------------------- justfile | 5 +---- 9 files changed, 57 insertions(+), 70 deletions(-) create mode 100644 .dockerignore delete mode 100644 .woodpecker/cron-docker-builder.yml delete mode 100644 .woodpecker/push-next.yml delete mode 100644 .woodpecker/tag-created.yml delete mode 100644 Dockerfile.builder diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..9f97022 --- /dev/null +++ b/.dockerignore @@ -0,0 +1 @@ +target/ \ No newline at end of file diff --git a/.forgejo/workflows/push-main.yml b/.forgejo/workflows/push-main.yml index 3c151ab..f0a8db2 100644 --- a/.forgejo/workflows/push-main.yml +++ b/.forgejo/workflows/push-main.yml @@ -33,3 +33,23 @@ jobs: args: release-plz release --backend gitea --git-token ${{ secrets.FORGEJO_TOKEN }} env: CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }} + + docker: + runs-on: docker + steps: + - name: Login to Forgejo + uses: docker/login-action@v3 + with: + registry: git.kemitix.net + username: ${{ vars.FORGEJO_USERNAME }} + password: ${{ secrets.FORGEJO_TOKEN }} + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + + - name: Build and push + uses: docker/build-push-action@v6 + with: + context: ./ + push: true + tags: git.kemitix.net/${{ vars.FORGEJO_USERNAME }}/${{ vars.FORGEJO_IMAGE_NAME }}:latest diff --git a/.forgejo/workflows/push-next.yml b/.forgejo/workflows/push-next.yml index 024d701..cf62142 100644 --- a/.forgejo/workflows/push-next.yml +++ b/.forgejo/workflows/push-next.yml @@ -50,3 +50,27 @@ jobs: uses: https://git.kemitix.net/kemitix/rust@v2.5.0 with: args: ${{ matrix.toolchain.name }} cargo hack --feature-powerset test + + docker: + runs-on: ubuntu-24.04 + steps: + + - name: Login to Forgejo + uses: docker/login-action@v3 + with: + registry: git.kemitix.net + username: ${{ vars.FORGEJO_USERNAME }} + password: ${{ secrets.FORGEJO_TOKEN }} + +# - name: Set up Docker Buildx +# uses: docker/setup-buildx-action@v3 + +# - name: Docker info (all setup) +# run: docker info + + - name: Build and push + uses: docker/build-push-action@v6 + with: + context: ./ + push: false # don't push on next, only on main + tags: git.kemitix.net/${{ vars.FORGEJO_USERNAME }}/${{ vars.FORGEJO_IMAGE_NAME }}:latest diff --git a/.woodpecker/cron-docker-builder.yml b/.woodpecker/cron-docker-builder.yml deleted file mode 100644 index ebf1c9c..0000000 --- a/.woodpecker/cron-docker-builder.yml +++ /dev/null @@ -1,15 +0,0 @@ -steps: - - update-builder-image: - when: - - event: cron - image: docker.io/woodpeckerci/plugin-docker-buildx:latest - settings: - username: kemitix - repo: git.kemitix.net/kemitix/git-next-builder - auto_tag: true - dockerfile: Dockerfile.builder - dry-run: false # push to remote repo - registry: git.kemitix.net - password: - from_secret: woodpecker-docker-push diff --git a/.woodpecker/push-next.yml b/.woodpecker/push-next.yml deleted file mode 100644 index 69fcb7e..0000000 --- a/.woodpecker/push-next.yml +++ /dev/null @@ -1,13 +0,0 @@ -steps: - docker-build: - when: - - event: push - branch: next - # INFO: https://woodpecker-ci.org/plugins/Docker%20Buildx - image: docker.io/woodpeckerci/plugin-docker-buildx:5.1.0 - settings: - username: kemitix - repo: git.kemitix.net/kemitix/git-next - dockerfile: Dockerfile - auto_tag: false - dry-run: true # don't push to remote repo diff --git a/.woodpecker/tag-created.yml b/.woodpecker/tag-created.yml deleted file mode 100644 index 5ccd3a1..0000000 --- a/.woodpecker/tag-created.yml +++ /dev/null @@ -1,16 +0,0 @@ -steps: - docker-build: - when: - - event: tag - ref: refs/tags/v* - # INFO: https://woodpecker-ci.org/plugins/Docker%20Buildx - image: docker.io/woodpeckerci/plugin-docker-buildx:5.1.0 - settings: - username: kemitix - repo: git.kemitix.net/kemitix/git-next - dockerfile: Dockerfile - auto_tag: true - dry-run: false # push to remote repo - registry: git.kemitix.net - password: - from_secret: woodpecker-docker-push diff --git a/Dockerfile b/Dockerfile index dfa8aa0..53c66d0 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,6 +1,16 @@ # Leveraging the pre-built Docker images with # cargo-chef and the Rust toolchain -FROM git.kemitix.net/kemitix/git-next-builder:2024.08.04 AS chef +FROM docker.io/rust:1.83.0-bookworm AS chef + +RUN apt-get update && \ + apt-get install -y libdbus-1-dev && \ + curl -L https://github.com/cargo-bins/cargo-binstall/releases/latest/download/cargo-binstall-x86_64-unknown-linux-musl.tgz -o cargo-binstall.tgz && \ + tar -xzf cargo-binstall.tgz && \ + rm cargo-binstall.tgz && \ + mv cargo-binstall /usr/local/bin/ && \ + cargo binstall -y cargo-chef && \ + rustup component add rustfmt clippy + WORKDIR /app FROM chef AS planner diff --git a/Dockerfile.builder b/Dockerfile.builder deleted file mode 100644 index 5f44d5c..0000000 --- a/Dockerfile.builder +++ /dev/null @@ -1,21 +0,0 @@ -FROM docker.io/rust:1.83.0-bookworm - -RUN apt-get update && \ - apt-get install -y libdbus-1-dev && \ - curl -L https://github.com/cargo-bins/cargo-binstall/releases/latest/download/cargo-binstall-x86_64-unknown-linux-musl.tgz -o cargo-binstall.tgz && \ - tar -xzf cargo-binstall.tgz && \ - rm cargo-binstall.tgz && \ - mv cargo-binstall /usr/local/bin/ && \ - cargo binstall -y cargo-chef && \ - rustup component add rustfmt clippy - -# verify that the binaries are installed -RUN ls -l /usr/local/cargo/bin/ -RUN cargo chef --version -RUN rustfmt --version -RUN cargo fmt --version -RUN cargo clippy --version -RUN cargo --version -RUN rustc --version -RUN rustup --version -RUN rustup show diff --git a/justfile b/justfile index bed34a5..99044af 100644 --- a/justfile +++ b/justfile @@ -60,10 +60,7 @@ grcov-coverage: find . -name '*.profraw' -exec rm "{}" \; echo "Now:\n\topen target/debug/coverage/index.html" -docker-build-builder: - docker build -t git.kemitix.net/kemitix/git-next-builder:2024.08.04 -f Dockerfile.builder . - -docker-build: docker-build-builder +docker-build: docker build -t git.kemitix.net/kemitix/git-next:latest . docker-run: docker-build