From 108d0aac251caa6e95f661baa68e562ba6039ffa Mon Sep 17 00:00:00 2001 From: "David A." <3106338+Dakad@users.noreply.github.com> Date: Sun, 9 Feb 2025 16:25:50 +0100 Subject: [PATCH 1/3] Add Hadolint configuration and linting workflow - Create .hadolint.yaml with custom linting rules - Add GitHub Actions workflow for Dockerfile linting - Configure Hadolint to ignore specific rules and use verbose output --- .github/workflows/hadolint.yml | 15 +++++++++++++++ .hadolint.yaml | 14 ++++++++++++++ 2 files changed, 29 insertions(+) create mode 100644 .github/workflows/hadolint.yml create mode 100644 .hadolint.yaml diff --git a/.github/workflows/hadolint.yml b/.github/workflows/hadolint.yml new file mode 100644 index 0000000..c0a577a --- /dev/null +++ b/.github/workflows/hadolint.yml @@ -0,0 +1,15 @@ +name: Hadolint - Dockerfile linting +on: + workflow_dispatch: + pull_request: + types: [opened, synchronize] + paths: + - "Dockerfile" +jobs: + hadolint: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: hadolint/hadolint-action@v3.1.0 + with: + verbose: true diff --git a/.hadolint.yaml b/.hadolint.yaml new file mode 100644 index 0000000..77a9be4 --- /dev/null +++ b/.hadolint.yaml @@ -0,0 +1,14 @@ + # list of rules: https://github.com/hadolint/hadolint/wiki +ignored: + - DL3008 # Pin versions in apt-get install - https://github.com/hadolint/hadolint/wiki/DL3008 + # - DL3018 # Pin versions in apk add - https://github.com/hadolint/hadolint/wiki/DL3018 + # - DL3028 # Pin version in gem install - https://github.com/hadolint/hadolint/wiki/DL3028 + +trustedRegistries: + - docker.io + - "*.gcr.io" + - "*.ecr.eu-west-1.amazonaws.com" + +override: + warning: + - DL3028 # Pin version in gem install - https://github.com/hadolint/hadolint/wiki/DL3028 \ No newline at end of file From 9038bbf09db17707382cdffc1f56c538f5dd99be Mon Sep 17 00:00:00 2001 From: "David A." <3106338+Dakad@users.noreply.github.com> Date: Sun, 9 Feb 2025 17:15:20 +0100 Subject: [PATCH 2/3] Add GitHub Actions workflow for Docker image build and publish - Create workflow to build and push Docker image to GitHub Container Registry - Support building on use_head_commit branch and version tags - Configure metadata and tagging for Docker images - Add artifact attestation for build provenance --- .../build-and-publish-docker-image.yaml | 60 +++++++++++++++++++ 1 file changed, 60 insertions(+) create mode 100644 .github/workflows/build-and-publish-docker-image.yaml diff --git a/.github/workflows/build-and-publish-docker-image.yaml b/.github/workflows/build-and-publish-docker-image.yaml new file mode 100644 index 0000000..99e02d4 --- /dev/null +++ b/.github/workflows/build-and-publish-docker-image.yaml @@ -0,0 +1,60 @@ +name: Build and publish docker image +on: + workflow_dispatch: + push: + branches: + - main + - use_head_commit + tags: + # any tag names starting with 'v' + - 'v*' +env: + REGISTRY: ghcr.io + IMAGE_NAME: ${{ github.repository }} + +jobs: + build: + runs-on: ubuntu-latest + permissions: + contents: read + # Gives the action the ability to mint the OIDC token necessary to request a Sigstore signing certificate + id-token: write + # Permission necessary to persist the attestation + attestations: write + steps: + - name: Checkout repository + uses: actions/checkout@v4 + - name: Set-up Docker Buildx + uses: docker/setup-buildx-action@v3 + with: + platforms: linux/amd64 + - name: Log in to the Github Container registry + uses: docker/login-action@v3 + with: + registry: ${{ env.REGISTRY }} + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + - name: Extract metadata (tags, labels) for Docker + id: meta + uses: docker/metadata-action@v5 + with: + images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} + tags: | + type=ref,event=branch + type=ref,event=pr + type=semver,pattern={{version}} + type=semver,pattern={{major}}.{{minor}} + - name: Build and push Docker image + id: push + uses: docker/build-push-action@v6 + with: + context: . + push: true + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} + - name: Generate artifact attestation + uses: actions/attest-build-provenance@v2 + with: + subject-name: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME}} + subject-digest: ${{ steps.push.outputs.digest }} + push-to-registry: true \ No newline at end of file From aa8ebdec4315de6b7c8901dae42764d55ae93001 Mon Sep 17 00:00:00 2001 From: "David A." <3106338+Dakad@users.noreply.github.com> Date: Mon, 2 Feb 2026 10:56:08 +0100 Subject: [PATCH 3/3] Update Dockerfile and Gemfile.lock for Ruby and Bundler versions - Upgrade Ruby base image to 3.4 - Bump Bundler version from 2.6.3 to 2.6.7 - Update maintainer and add additional metadata labels in Dockerfile - Ensure proper installation of required packages --- .ruby-version | 2 +- Dockerfile | 44 +++++++++++++++++++++++++++++--------------- Gemfile.lock | 2 +- 3 files changed, 31 insertions(+), 17 deletions(-) diff --git a/.ruby-version b/.ruby-version index 010d183..7921bd0 100644 --- a/.ruby-version +++ b/.ruby-version @@ -1 +1 @@ -3.3.7 \ No newline at end of file +3.4.8 diff --git a/Dockerfile b/Dockerfile index b914405..a09a44c 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,20 +1,34 @@ -FROM ruby:3.3 +ARG RUBY_VERSION=3.4 +FROM ruby:${RUBY_VERSION} -LABEL maintainer="QAWAII " -LABEL org.opencontainers.image.source https://github.com/apptweak/pronto-ruby - -ARG BUNDLER_VERSION="2.6.3" +ARG BUNDLER_VERSION="2.6.7" ARG NODE_VERSION=14 +ARG BUILD_DATE= +ARG CVS_REF= -RUN apt-get update && \ - apt-get install -y --no-install-recommends \ - build-essential \ - cmake \ - curl \ - git \ - pkg-config \ - openssl \ - && rm -rf /var/lib/apt/lists/* +LABEL maintainer="DevEx Team " +LABEL org.opencontainers.image.source https://github.com/apptweak/pronto-ruby +LABEL org.opencontainers.image.title="AppTweak Pronto Ruby Runner" +LABEL org.opencontainers.image.description="GitHub Action for running Pronto code review automation for Ruby projects" +LABEL org.opencontainers.image.source="https://github.com/apptweak/pronto-ruby" +LABEL org.opencontainers.image.url="https://github.com/apptweak/pronto-ruby" +LABEL org.opencontainers.image.vendor="AppTweak" +LABEL org.opencontainers.image.version=${CVS_REF} +LABEL org.opencontainers.image.created=${BUILD_DATE} + +RUN apt-get update \ + && apt-get install -y --no-install-recommends \ + build-essential \ + cmake \ + curl \ + git \ + pkg-config \ + openssl \ + && rm -rf /var/lib/apt/lists/* + +# Make sure to use bash with pipefail in case something +# fails while being piped to another command in the docker-build +SHELL ["/bin/bash", "-o", "pipefail", "-c"] RUN gem install bundler --version "${BUNDLER_VERSION}" @@ -24,7 +38,7 @@ COPY Gemfile* ./ RUN bundle --retry 4 -ENV BUNDLE_GEMFILE /runner/Gemfile +ENV BUNDLE_GEMFILE=/runner/Gemfile COPY . ./ diff --git a/Gemfile.lock b/Gemfile.lock index 9f22532..e094ee2 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -339,4 +339,4 @@ DEPENDENCIES webmock BUNDLED WITH - 2.6.3 + 2.6.7