-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
soci in codebuild: containerd mountpoint? #4
Comments
Hey @jrobison-sb sorry for the delayed response, I didn't have notifications turned on for this repo (I do now) 😞 I looked into creating a SOCI Index in codebuild again today and realized we don't actually need to run a second containerd daemon. As there is already a containerd daemon (with an accessible socket) running in the environment underneath codebuild's Docker Engine. We can just leverage that instead, removing all of the filesystem / mount restrictions of containers in containers. The containerd endpoint is at I've updated the CodeBuild sample in this repo. But the gist is, I create the container image and export it as a tarball in a single - echo Building the container image
- docker buildx create --driver=docker-container --use
- docker buildx build --quiet --tag $IMAGE_URI:$IMAGE_TAG --file Dockerfile.v2 --output type=oci,dest=./image.tar .
- echo Import the container image to containerd
- ctr image import ./image.tar
- echo Generating SOCI index
- soci create $IMAGE_URI:$IMAGE_TAG
- echo Pushing the container image
- ctr image push --user AWS:$PASSWORD $IMAGE_URI:$IMAGE_TAG
- echo Push the SOCI index to ECR
- soci push --user AWS:$PASSWORD $IMAGE_URI:$IMAGE_ |
@ollypom thanks for your reply. These new directions without an intermediate push-pull step are much cleaner, thanks for that. I gave this another try using the updated directions. We currently use Codebuild AL2 standard:2.0 image on arm64, which ships with Docker v20. I'm guessing that Docker v20 isn't compatible with the new suggestions (specifically the This would probably work if we upgraded to AL2 standard:3.0 image on arm64 (which ships with Docker v23), but apparently I guess I'll just have to wait for aws/aws-codebuild-docker-images#640 to be resolved and then revisit this. |
Oh interesting. I didn't realize I have now added an alternative method for arm64 in a multi architecture example. This example uses For the arm64 image here are the steps to create the image, export it, and then import it back into containerd. This should work with any Docker version (including the x86 image). - echo Building the container image
- docker build --quiet --tag $IMAGE_URI:$IMAGE_TAG --file Dockerfile.v2 .
- echo Export the container image
- docker save --output ./image.tar $IMAGE_URI:$IMAGE_TAG
- echo Import the container image to containerd
- ctr image import ./image.tar |
I couldn't get any of the examples to work for various reasons. I ended up forking the Lambda snapshotter and making it standalone so I can use it in CodeBuild with no dependencies. You might also find it useful for your use case. |
@jrobison-sb Looks like the arm64 CodeBuild image now includes Buildx :) @kichik ooh interesting, thank you for sharing. I've transferred this over to a feature request in the soci-snapshotter repository to see if there is appetite to support |
I have the same use case as this ticket. I am trying to create an index in CodeBuild. Specifically here. |
@ollypom thanks for the new simplified directions. Using those directions I'm able to:
And all of the above works fine. But then when I try to
I googled the error but didn't find anything, unfortunately. I assume there's probably just not that many folks on earth who are building SOCI indexes just yet. Have you seen this one before? Is it a conflict that I push the image to ECR by way of Thanks for any thoughts you might have on this. Full buildspec and other codebuild specifics here.Codebuild image: Base image in our Dockerfile: Buildspec (with some business-y logic removed, but this should illustrate what we're doing with docker, at least):
|
@jrobison-sb you are correct. The container image digest changes through the In this context, you have indexed a container image with a digest that starts To work around this, push the container image with aws-fargate-seekable-oci-toolbox/soci-codepipeline/multiarch-cloudformation.yaml Line 234 in bf00dcb
|
@ollypom does this affect the export the Lambda solution does as well? With my fork of the Lambda solution, I am able to push indexes, but they don't seem to be used (checked with |
@ollypom thanks for your reply. But even now that I've gotten this working, I do still have an appetite for awslabs/soci-snapshotter#1057 and would definitely use it if it ever became a thing. If I was to ever quit my job or get hit by a bus or something, I would expect the next engineer to already be familiar with the usual Anyway, now that I've gotten this working, I don't need any additional help from @ollypom. I'll leave this ticket open to allow the discussion with @kichik to continue, though. Thanks again. |
Hey @kichik it does not, if you have the three artifacts in your ECR repository (1) container Image (2) SOCI Index (3) OCI image Index (used to map the SOCI Index to the container image) then you should be good to go with Fargate. Artifacts 2 and 3 are what are created by the lambda / your standalone tool. With the assumption that the considerations in the ECS documentation have been met. Happy to help troubleshoot over DM / call if its easier. Hey @jrobison-sb completely understandable. In the latest versions of Docker (v24 and v25) you can index images that have been built with |
That would be really appreciated. I only see Soci Index in ECR. There is no Image Index. Where can I DM you? I'm on CDK Slack, Twitter or whatever works. |
@ollypom is it possible to use zstd compression as well? If yes, what needs to be changed in the above commands? |
Hey @uhaiderdev , unfortunately the SOCI snapshotter does not support zstd compression at the moment, it is tracked in the upstream project here. |
@ollypom I am using the aws/codebuild/amazonlinux2-x86_64-standard:4.0 image in CodeBuild with Environment Type Linux EC2 and compute type EC2. I tried the following
What could be the problem? Thanks |
Hey @uhaiderdev, I'm unable to recreate you're issue. Are you able to share your buildspec file? The environment that I used to try and recreate your issue is as follows:
(FWIW there is no "Environment Type Linux EC2 and compute type EC2" as per the reference guide) And then my commands are the same mentioned above in this thread, but I have also explicitly set the CONTAINERD_ADDRESS.
|
We're using @kichik 's standalone indexer and it it's working fine as container startup times on ECS fargate have essentially halved 🎉 . We also do use a custom docker image for running codebuild containers as we want full control over the build environment. Does anyone have an idea if when we build SOCI layers for our codebuild image as well, that it will be used by the codebuild runner? It seems like the indices have no impact yet. We're seeing CodeBuild provisioning times of about ~45s - 1m, which could be more in the 15-20s area I think. |
My goal is to build soci indexes inside AWS codebuild, like this.
When I try setting up containerd using a tmpfs mountpoint,
ctr image pull ...
seems to work at first, but it runs out of disk space because tmpfs defaults to having a disk size which is equivalent to .5X RAM, and my image is greater than this size.When I try setting up containerd without using a tmpfs mountpoint, like this:
Then
ctr image pull ...
fails with an error sayingfailed to convert whiteout file
.Do you have any suggestion for building these indexes inside Codebuild when my image size is greater than .5X RAM?
Thanks.
The text was updated successfully, but these errors were encountered: