Skip to content
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

Cache layer with docker to speed up the development workflow #242

Open
francescotaioli opened this issue Sep 3, 2021 · 2 comments
Open
Labels
area/build area/docker stage/pm-review Waiting for review by our Product Manager, please don't work on this yet type/feature

Comments

@francescotaioli
Copy link

Describe your idea/feature/enhancement

[Project: sam init - python 3.8 - image container (not zip file)]
sam build always rebuild the image even if:

  • requirements.txt is not changed
  • the code is not changed

Proposal

At least in development, we could change to Dockerfile to cache the layers that didn't changed, such as requirments.txt. When someone has a slow connection, it take A LOT of time.

In order to do this, the default Dockerfile should be changed in:
New Dockerfile

FROM public.ecr.aws/lambda/python:3.8 AS build

COPY requirements.txt ./
RUN python3.8 -m pip install -r requirements.txt -t .

COPY app.py ./
COPY model /opt/ml/model

CMD ["app.lambda_handler"]

Old Dockerfile

FROM public.ecr.aws/lambda/python:3.8

COPY app.py requirements.txt ./
COPY model /opt/ml/model

RUN python3.8 -m pip install -r requirements.txt -t .

CMD ["app.lambda_handler"]

Additional Details

@awood45
Copy link
Member

awood45 commented Sep 3, 2021

This makes sense as a feature request - one reason the build behaves this way is that even if, for example, requirements.txt is unchanged, dependencies may have changed within constraints and a rebuild can be appropriate/intended. However, I can see where options to limit the layers built can come in handy.

@awood45 awood45 added the stage/pm-review Waiting for review by our Product Manager, please don't work on this yet label Sep 3, 2021
@mndeveci mndeveci transferred this issue from aws/aws-sam-cli May 16, 2022
@sleepwithcoffee
Copy link
Contributor

I think we can close this ticket as it is addressed under #362

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/build area/docker stage/pm-review Waiting for review by our Product Manager, please don't work on this yet type/feature
Projects
None yet
Development

No branches or pull requests

3 participants