Giter Club home page Giter Club logo

Comments (3)

gaocegege avatar gaocegege commented on June 29, 2024

One new reason to split system dependencies and pypi deps is to install them separately and then merge them in one layer to accelerate the process.

func base() llb.State {
	python := llb.Image("docker.io/library/python:3.8")
	run1 := python.Run(llb.Shlex("pip install -i https://mirror.sjtu.edu.cn/pypi/web/simple jupyter"))
	run1.AddMount("/root/.cache/pip", llb.Scratch())
	run1.AddMount("/root/.cache/pip", llb.Scratch(), llb.AsPersistentCacheDir("//root/.cache/pip", llb.CacheMountShared))
	run := python.
		Run(llb.Shlex("pip install -i https://mirror.sjtu.edu.cn/pypi/web/simple ormb"))
	run.AddMount("/root/.cache/pip", llb.Scratch())
	run.AddMount("/root/.cache/pip", llb.Scratch(), llb.AsPersistentCacheDir("//root/.cache/pip", llb.CacheMountShared))
	new := llb.Merge([]llb.State{run.State, run1.State})
	return new
}

from envd.

gaocegege avatar gaocegege commented on June 29, 2024

One way to accelerate the process: Make a tiny image which contains pip/apt, then use the image to pip install deps. And finally merge the base image with them.

func base() llb.State {
        // Maybe large!
	python := llb.Image("docker.io/library/python:3.8")
	run1 := some-tiny-image.Run(llb.Shlex("pip install -i https://mirror.sjtu.edu.cn/pypi/web/simple jupyter"))
	run1.AddMount("/root/.cache/pip", llb.Scratch())
	run1.AddMount("/root/.cache/pip", llb.Scratch(), llb.AsPersistentCacheDir("//root/.cache/pip", llb.CacheMountShared))
	run := some-tiny-image.
		Run(llb.Shlex("pip install -i https://mirror.sjtu.edu.cn/pypi/web/simple ormb"))
	run.AddMount("/root/.cache/pip", llb.Scratch())
	run.AddMount("/root/.cache/pip", llb.Scratch(), llb.AsPersistentCacheDir("//root/.cache/pip", llb.CacheMountShared))
	new := llb.Merge([]llb.State{python, run.State, run1.State})
	return new
}

from envd.

gaocegege avatar gaocegege commented on June 29, 2024

Let's keep the rules to:

install_package(
    name = ['vscode', 'gdb>9', 'ssh', 'g++'],
    optional = True
)

pip_package(
    name = ['numpy', 'pandas']
)

from envd.

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.