Skip to content

Commit

Permalink
build: enable multi-arch cache mount in Docker build
Browse files Browse the repository at this point in the history
- Add multi-architecture support arguments `TARGETARCH` and `TARGETVARIANT` to base and build stages.
- Move cache mount for multi-architecture setup to earlier in the build stage.

Signed-off-by: CHEN, CHUN <[email protected]>
  • Loading branch information
jim60105 committed Dec 31, 2024
1 parent 3a997e3 commit be9888c
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions ubi.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,10 @@ ARG HF_HOME=${CACHE_HOME}/huggingface
########################################
FROM registry.access.redhat.com/ubi9/ubi-minimal AS base

# RUN mount cache for multi-arch: https://github.com/docker/buildx/issues/549#issuecomment-1788297892
ARG TARGETARCH
ARG TARGETVARIANT

ENV PYTHON_VERSION=3.11
ENV PYTHONUNBUFFERED=1
ENV PYTHONIOENCODING=UTF-8
Expand All @@ -48,15 +52,15 @@ RUN --mount=type=cache,id=dnf-$TARGETARCH$TARGETVARIANT,sharing=locked,target=/v
########################################
FROM base AS build

# RUN mount cache for multi-arch: https://github.com/docker/buildx/issues/549#issuecomment-1788297892
ARG TARGETARCH
ARG TARGETVARIANT

# Install build time requirements
RUN --mount=type=cache,id=dnf-$TARGETARCH$TARGETVARIANT,sharing=locked,target=/var/cache/dnf \
microdnf -y install --setopt=install_weak_deps=0 --setopt=tsflags=nodocs \
git python3.11-pip findutils

# RUN mount cache for multi-arch: https://github.com/docker/buildx/issues/549#issuecomment-1788297892
ARG TARGETARCH
ARG TARGETVARIANT

WORKDIR /app

# Install under /root/.local
Expand Down

0 comments on commit be9888c

Please sign in to comment.