Open ayushchd opened 2 years ago
If docker is pulling new images, the delay should come after Step 1/20 : FROM public.ecr.aws/lambda/python:3.8
is printed. This seems to be a docker issue as SAM CLI directly calls docker build after Setting DockerBuildArgs
.
What is your docker version? Can you try updating it to a newer version and/or factory reset the settings?
Hi,
sam build or sam build --cached are extremely slow. No matter what I try it results in a very slow process.
Thank You very much!
Have you looked into your docker version? Have you tried to update your docker or factory reset it?
It might be a local system issue.
I have the same issue on an M1 mac.
It's definitely not docker, I can build the image just fine using docker build
.
On the other hand, i've tried:
sam build
sam build --parallel
sam build --parallel --skip-pull-image
And they are all extremely slow, it also momentarily blocks my machine as it consumes an inordinate amount of memory.
Every once in a while i also get this error,
I'm also seeing this; a huge delay (4-5 minutes) after the DockerBuildArgs step before (as far as I can tell) it actually starts doing the docker build. Last couple of lines of log before the pause, and then first couple of lines of the actual docker build running below.
...
2022-08-07 23:44:08,229 | Building codeuri: /Users/kwamina/givedirectly/ubi/image_updater runtime: None metadata: {'Dockerfile': 'tools/Dockerfile', 'DockerContext': '/Users/kwamina/givedirectly', 'DockerTag': 'latest', 'DockerBuildArgs': {'IMAGE_BASE': 'public.ecr.aws/lambda/python:3.9', 'PROJECT_ROOT': 'ubi/image_updater', 'PROJECT_SOURCE': 'ubi/image_updater/image_updater', 'PROJECT_CMD': 'image_updater.lambda_function.lambda_handler'}} architecture: x86_64 functions: ImageUpdaterFunction
2022-08-07 23:44:08,229 | Building to following folder /Users/kwamina/givedirectly/ubi/image_updater/.aws-sam/build/ImageUpdaterFunction
2022-08-07 23:44:08,229 | Building image for ImageUpdaterFunction function
2022-08-07 23:44:08,234 | Setting DockerBuildArgs: {'IMAGE_BASE': 'public.ecr.aws/lambda/python:3.9', 'PROJECT_ROOT': 'ubi/image_updater', 'PROJECT_SOURCE': 'ubi/image_updater/image_updater', 'PROJECT_CMD': 'image_updater.lambda_function.lambda_handler'} for ImageUpdaterFunction function
[4-5 MINUTE PAUSE HERE]
Step 1/32 : ARG IMAGE_BASE=python:3.9-alpine
Step 2/32 : FROM alpine as collect_local_deps
---> d7d3d98c851f
Step 3/32 : ARG PROJECT_ROOT
---> Using cache
---> ac073187e354
Step 4/32 : RUN apk add --no-cache coreutils
---> Using cache
---> 9935386e8e0c
...
This is interesting, I'm not able to reproduce this at this time. Do you see this happening for every build or for a certain image?
I am facing same issue on M1 system
Hi, could anyone experiencing this issue provide us with a sample project and steps to reproduce?
I was having this issue as well, but I was able to resolve it just by adding a .dockerignore file. In my SAM template I had DockerContext set to the project root for every function, which contains a lot of unrelated files. Ignoring everything but the function source files dramatically sped things up
yes!
i'm using this alongside https://github.com/iterative/dvc
I have a cache of possibly gigabytes of data. There might be some rogue process going through these files
Any update in this issue?
I fixed this issue by following @rmaccrimm's solution. I added large folders such as "node_modules" and cache folders to the .dockerignore
file, making the build much faster.
According to Docker's official document:
This helps avoid sending unwanted files and directories to the builder, improving build speed, especially when using a remote builder.
Description:
I am using
sam-build
to build a SAM application that has a lambda with package type asImage
. Every time I executesam-build
(event with--cached --parallel --skip-pull-image
) it seems to take a lot of time at a certain step. From verbose logs, it looks like there's some step that takes time after this line:and then after about 3-4 minutes, I see this lines that quickly execute:
It seems to me that it's pulling the base image
public.ecr.aws/lambda/python:3.8
on every build request.Steps to reproduce:
Dockerfile:
Observed result:
The latency/delay is after
Setting DockerBuildArgs: {} for ReportsGeneratorFunction function
Expected result:
It should reuse the previous image (if that's the reason for the delay)
Additional environment details (Ex: Windows, Mac, Amazon Linux etc)
sam --version
: SAM CLI, version 1.34.1Add --debug flag to command you are running