Skip to content

Commit 45f39a3

Browse files
committed
fix(docker): Mount /tmp and /home as tmpfs during ort requirements
This prevents caches and temporary files from being persisted to the image, reducing its size by ~500 MB. More importantly, it fixes an "AccessDenied" error when running with ort-ci-action. Burrito-based tools (mix_sbom, bombom) extract a musl runtime to /tmp on first run. When this happens during the Docker build, the files are owned by the ort user with mode 0754 (no execute for others). The ort-ci-action runs containers with -u $(id -u):$(id -g), so the user may not be ort and cannot execute the musl library. By using tmpfs mounts, these files are not persisted and each container creates them fresh with appropriate permissions. Signed-off-by: Jonatan Männchen <jonatan@maennchen.ch>
1 parent f0257be commit 45f39a3

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

Dockerfile

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -725,6 +725,10 @@ ENTRYPOINT ["/opt/ort/bin/ort"]
725725
# Runtime container with all supported package managers pre-installed.
726726
FROM all-tools AS run
727727

728+
ARG HOMEDIR=/home/ort
729+
ARG USER_ID=1000
730+
ARG USER_GID=$USER_ID
731+
728732
# ORT
729733
COPY --from=ortbin --chown=$USER:$USER /opt/ort /opt/ort
730734
ENV PATH=$PATH:/opt/ort/bin
@@ -739,6 +743,9 @@ RUN mkdir -p "$HOME/.ort" "$HOME/.gradle"
739743
RUN $CARGO_HOME/bin/cargo install cargo-credential-netrc
740744

741745
# Verify that all tools required by ORT are available.
742-
RUN ort requirements
746+
# Mount /tmp and $HOMEDIR as cache to prevent temporary files from being persisted to the image.
747+
RUN --mount=type=tmpfs,target=/tmp \
748+
--mount=type=cache,target=$HOMEDIR,uid=$USER_ID,gid=$USER_GID \
749+
ort requirements
743750

744751
ENTRYPOINT ["/opt/ort/bin/ort"]

0 commit comments

Comments
 (0)