From a39035119c7899901dfc785e59380d52b9b11986 Mon Sep 17 00:00:00 2001 From: KevFan Date: Fri, 5 Jan 2024 16:16:21 +0000 Subject: [PATCH] refactor: algin dockerfile build stages to use rust:1.72-bullseye --- .github/workflows/build-image.yaml | 6 ++++-- Dockerfile | 25 ++++++------------------- 2 files changed, 10 insertions(+), 21 deletions(-) diff --git a/.github/workflows/build-image.yaml b/.github/workflows/build-image.yaml index 096bd617..47192c51 100644 --- a/.github/workflows/build-image.yaml +++ b/.github/workflows/build-image.yaml @@ -22,8 +22,10 @@ jobs: include: - dockerfile: Dockerfile platform: linux/amd64 + scope: build-amd - dockerfile: Dockerfile.aarch64 platform: linux/arm64 + scope: build-arm steps: - name: Check out code uses: actions/checkout@v4 @@ -49,8 +51,8 @@ jobs: labels: ${{ steps.meta.outputs.labels }} build-args: | GITHUB_SHA=${{ github.sha }} - cache-from: type=gha,scope=${{ matrix.platform == 'linux/amd64' && 'build-amd' || 'build-arm'}} - cache-to: type=gha,mode=max,scope=${{ matrix.platform == 'linux/amd64' && 'build-amd' || 'build-arm'}} + cache-from: type=gha,scope=${{ matrix.scope }} + cache-to: type=gha,mode=max,scope=${{ matrix.scope}} outputs: type=image,name=${{ env.IMG_REGISTRY_HOST }}/${{ env.IMG_REGISTRY_ORG }}/limitador,push-by-digest=true,name-canonical=true,push=true file: ${{ matrix.dockerfile }} platforms: | diff --git a/Dockerfile b/Dockerfile index 7bbb489d..5c524cce 100644 --- a/Dockerfile +++ b/Dockerfile @@ -2,24 +2,12 @@ # Build Stage # ------------------------------------------------------------------------------ -FROM registry.access.redhat.com/ubi9/ubi:9.2 as limitador-build -ENV CARGO_NET_GIT_FETCH_WITH_CLI=true +# Use bullseye as build image instead of Bookworm as ubi9 does not not have GLIBCXX_3.4.30 +# https://access.redhat.com/solutions/6969351 +FROM --platform=${BUILDPLATFORM} rust:1.72-bullseye as limitador-build -ARG RUSTC_VERSION=1.72.0 - -# the powertools repo is required for protobuf-c and protobuf-devel -RUN dnf -y --setopt=install_weak_deps=False --setopt=tsflags=nodocs install \ - https://mirror.stream.centos.org/9-stream/BaseOS/`arch`/os/Packages/centos-gpg-keys-9.0-23.el9.noarch.rpm \ - https://mirror.stream.centos.org/9-stream/BaseOS/`arch`/os/Packages/centos-stream-repos-9.0-23.el9.noarch.rpm \ - && dnf -y --setopt=install_weak_deps=False --setopt=tsflags=nodocs install epel-release \ - && dnf config-manager --set-enabled crb - -RUN PKGS="protobuf-devel git clang perl" \ - && dnf install --nodocs --assumeyes $PKGS \ - && rpm --verify --nogroup --nouser $PKGS \ - && yum -y clean all - -RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- --no-modify-path --profile minimal --default-toolchain ${RUSTC_VERSION} -c rustfmt -y +RUN apt update && apt upgrade -y \ + && apt install -y protobuf-compiler clang WORKDIR /usr/src/limitador @@ -29,8 +17,7 @@ ENV RUSTFLAGS="-C target-feature=-crt-static" COPY . . -RUN source $HOME/.cargo/env \ - && cargo build --release +RUN cargo build --release # ------------------------------------------------------------------------------ # Run Stage