Giter Site home page Giter Site logo

How to leverage caching? about docker-lambda HOT 6 CLOSED

lambci avatar lambci commented on July 24, 2024
How to leverage caching?

from docker-lambda.

Comments (6)

mhart avatar mhart commented on July 24, 2024 1

And another thing I could suggest would be to setup a Dockerfile that uses lambci/lambda:build-python2.7 as a base and do your build in steps – that way you can leverage the caching that Docker layers provide you

from docker-lambda.

mhart avatar mhart commented on July 24, 2024

If you're using the build image, then why not just put the cache directory in the current directory and save the extra -v call? Does that work for you?

from docker-lambda.

mhart avatar mhart commented on July 24, 2024

Btw – this sounds like a pip error? Like, because it's being executed by root. Is there not some pip configuration you can change to ignore that error?

Other ppl run into similar issues in Docker here: pypa/pip#3596

from docker-lambda.

josegonzalez avatar josegonzalez commented on July 24, 2024
$ docker run --rm -v "$PWD":/var/task lambci/lambda:build-python2.7 pip install -r requirements.txt --cache-dir /var/task/.cache -t env
The directory '/var/task/.cache/http' or its parent directory is not owned by the current user and the cache has been disabled. Please check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.
The directory '/var/task/.cache' or its parent directory is not owned by the current user and caching wheels has been disabled. check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.

from docker-lambda.

mhart avatar mhart commented on July 24, 2024

A few other things I could suggest:

  1. Try a different directory that's not /tmp or /var/task – like /root/.cache
  2. Change ownership of the directory, like:
docker run --rm -v "$PWD":/var/task lambci/lambda:build-python2.7 bash -c \
  'chown -R root /var/task/.cache && pip install -r requirements.txt --cache-dir /var/task/.cache -t env'

from docker-lambda.

josegonzalez avatar josegonzalez commented on July 24, 2024

I have this which seems to work:

docker run --rm -v \"$PWD\":/var/task lambci/lambda:build-python2.7 bash -c \
    'rsync -a /var/task/.cache/ /root/.cache/ || true && chown -R root /root/.cache && pip install -r requirements.txt -t env && rsync -a /root/.cache/ /var/task/.cache/'

Not sure on how to make this more approachable, but definitely a step in the right direction!

from docker-lambda.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.