Caching in CI/CD #4536
-
I'm seeing some unexpected behavior when using the I'm running buildah by using this container image: quay.io/buildah/stable $ buildah --version
buildah version 1.28.0 (image-spec 1.0.2-dev, runtime-spec 1.0.2-dev) The command I am running in CI/CD is roughly the following: buildah build \
--layers \
--cache-from $CI_REGISTRY_IMAGE/cache \
--cache-to $CI_REGISTRY_IMAGE/cache \
--tag $REPOSITORY_URL:$IMAGE_TAG \
--secret id=aws-creds,src=/root/.aws/credentials \
--secret id=aws-config,src=/root/.aws/config \
--build-arg AWS_PROFILE=default \
. $CI_REGISTRY_IMAGE is a predefined variable that doesn't change, whose description can be found here: https://docs.gitlab.com/ee/ci/variables/predefined_variables.html The relevant snippet of the dockerfile is as follows: FROM public.ecr.aws/lambda/python:3.9 AS requirements_stage
# Install the AWS OTEL lambda layer and unpack it into /opt.
# Roughly following this guide:
# https://aws.amazon.com/blogs/compute/working-with-lambda-layers-and-extensions-in-container-images/
#
# Lambda layer ARN pulled from here:
# https://aws-otel.github.io/docs/getting-started/lambda/lambda-python#add-the-arn-of-the-lambda-layer
RUN yum install --assumeyes aws-cli curl unzip
RUN mkdir -p /opt
# The AWS_PROFILE variable needs to be set in order for the config profile to be picked
# up.
ARG AWS_PROFILE
# This mounts in the AWS credentials and AWS config file as secrets so they do not get
# stored in the final image.
# https://docs.docker.com/engine/reference/builder/#run---mounttypesecret
RUN --mount=type=secret,id=aws-creds,target=/root/.aws/credentials,required=true \
--mount=type=secret,id=aws-config,target=/root/.aws/config,required=true \
curl $( \
aws lambda get-layer-version-by-arn \
--arn arn:aws:lambda:us-west-2:901920570463:layer:aws-otel-python-amd64-ver-1-14-0:1 \
--query 'Content.Location' \
--output text \
) --output layer.zip
RUN unzip layer.zip -d /opt
RUN rm layer.zip I tried running this same build locally using the quay.io/buildah/stable image and podman. I was able to reproduce the issue if I did not use a bind mount to preserve the information in The issue is that I cannot cache Is there not a way to change where buildah stores its intermediate containers/layers/cache from |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 4 replies
-
The solution I found was to modify https://github.com/containers/buildah/blob/main/vendor/github.com/containers/storage/storage.conf https://github.com/containers/storage/blob/main/docs/containers-storage.conf.5.md Overriding the I also discovered that all the intermediate layers seem to be cached here. This means that using |
Beta Was this translation helpful? Give feedback.
-
@rhatdan I was thinking about this more today and was wondering if the behavior stated above is something worthy of an issue, or is this expected behavior? Summarized issue: Caching with |
Beta Was this translation helpful? Give feedback.
-
This issue appears resolved by buildah version |
Beta Was this translation helpful? Give feedback.
This issue appears resolved by buildah version
1.29.1
, though it may have been resolved by an earlier version. See: #4621