Giter Club home page Giter Club logo

Comments (4)

dwellner avatar dwellner commented on August 25, 2024

@mattgruter
@sfitts Did you find a solution for your problem?

I also find the addFile API a bit confusing. There seems to be 2 addFile overloads:

addFile(File file), which puts the given file in the output folder and adds it to the dockerfile as
ADD <file> /

This seems to be pretty useless, since usually files tend to go somewhere else than /.

Then there is addFile(Closure copySpec), which gives full control over copying the file, but that seems a bit unnecessary because typically the file just needs to go into the docker build folder. (stageDir)

Instead, if anyhow possible I would like to see something as simple as this

void addFile(File file, String destination) {
        stageDir.mkdir()
        project.copy {
            from file
            into stageDir
        }
        instructions.add("ADD ${file.name} " + destination)
    }

Or did I completely misunderstood something here?

from gradle-docker.

mattgruter avatar mattgruter commented on August 25, 2024

@sfitts
The addFile(Closure copySpec) API seems to be broken. Honestly I'm not sure how it ever worked. I'm working on a fix. So, no user error on your part.

@dwellner
The recommended way to use the addFile(File file) API is with tar archive files:

addFile file('archive.tar')

Adding tar archives in a Dockerfile implictly unpacks the archive (see http://docs.docker.io/reference/builder/#add).
The idea here is to add the docker payload by first creating a tar archive with the correct directory structure (e.g. an archive created by a distTar application task) and then passing the archive to addFile.

Until the addFile(Closure copySpec) API call is fixed, creating a tar archive is the most flexible way to add files. We'll probably also add a possibility to addFile(File file, String destination) in the next release (coming soon).

Cheers,
Matthias

from gradle-docker.

sfitts avatar sfitts commented on August 25, 2024

Thanks for the update and for the explanation of how the other variant is designed to be used.

from gradle-docker.

mattgruter avatar mattgruter commented on August 25, 2024

Fixed on branch 'dev'. Included in upcoming version 1.2

from gradle-docker.

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.