Skip to content

Commit

Permalink
refactor: algin dockerfile build stages to use rust:1.72-bullseye
Browse files Browse the repository at this point in the history
  • Loading branch information
KevFan committed Jan 5, 2024
1 parent ea032a9 commit db68416
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 21 deletions.
6 changes: 4 additions & 2 deletions .github/workflows/build-image.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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: |
Expand Down
25 changes: 6 additions & 19 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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
Expand Down

0 comments on commit db68416

Please sign in to comment.