Giter Club home page Giter Club logo

Comments (9)

thaJeztah avatar thaJeztah commented on August 24, 2024 3

Automatic extraction (with ADD) only works for local archives; if you only need the files, not the archive, it's better to just add the extracted files, instead of a zip, and later extracting during docker build.

If you're adding a remote archive; use a multi stage build, and decompress in an intermediate build-stage

from buildkit.

friism avatar friism commented on August 24, 2024

I think this is a dupe of moby/moby#15036

As mentioned in that issue, ADD id not recommend best practice so I'm not sure it's worth extending it.

from buildkit.

thecloudtaylor avatar thecloudtaylor commented on August 24, 2024

I'm not married to ADD as the keyword but the scenario is pretty valuable.

from buildkit.

friism avatar friism commented on August 24, 2024

@taylorb-microsoft the problem is that you typically don't want exactly what's in a .zip. Instead, you want the zip, do some transformation on the contents (eg. compile source code), and then get rid of anything from the zip you don't need. To keep image-size minimal, you want to do that in a single layer.

Here's an example: https://github.com/docker-library/golang/blob/master/1.8/windows/windowsservercore/Dockerfile#L15

Details here: https://docs.docker.com/engine/userguide/eng-image/dockerfile_best-practices/#add-or-copy

Do you have a specific use-case in mind?

from buildkit.

unclejack avatar unclejack commented on August 24, 2024

ADD has been frozen a few years ago. It's been discussed a bunch of times already on this issue tracker. The issue with ADD is that it has too much magic and it's pretty hard to keep track of all the edge cases when using the instruction in a Dockerfile.

ADD shouldn't be extended at all. Instead, new keywords which state the action to be taken explicitly should be introduced. COPY was the first instruction which was meant to help deprecate ADD in favor of specialized instructions. This means we should split up ADD into separate instructions. COPY already copies files. UNPACK or EXTRACT should handle various archives (.tar.gz, .tar.bz2, .tar.xz, .zip). Another instruction should exist for the retrieval of files from remote sources. This fetch instruction could also have a parameter which allow the archive to be extracted or just retrieved for storage as it is.

from buildkit.

thecloudtaylor avatar thecloudtaylor commented on August 24, 2024

Thanks, we are looking at bringing better compression tools support into Windows but it does seem like being able to accomplish these operations without starting a container might be beneficial.

from buildkit.

unclejack avatar unclejack commented on August 24, 2024

@taylorb-microsoft Perhaps this is something to discuss to come up with a new instruction for the Dockerfile. It really is a bad idea to overload ADD any further with any new functionality.

There's no reason why such functionality couldn't be added using a different new instruction (UNPACK, EXTRACT and so on). It's just that it needs a bit more effort to make sure we take into account all the various scenarios.

from buildkit.

synergiator avatar synergiator commented on August 24, 2024

But how do you integrate ZIP files then? AFAIK, the COPY instruction will create an image layer you do not need afterwards in most cases for this scenario.

This is a waste of space which will become noticable for large archives.

https://devops.stackexchange.com/questions/3172/copy-and-zip-files-in-dockerfile

from buildkit.

tandeday avatar tandeday commented on August 24, 2024

Automatic extraction (with ADD) only works for local archives; if you only need the files, not the archive, it's better to just add the extracted files, instead of a zip, and later extracting during docker build.

I need to be able to build under Windows and the NTFS filesystem mapping may not preserve the original metadata exactly, hence I would like to unpack an archive instead.

from buildkit.

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.