Uploaded image for project: 'Jenkins'
  1. Jenkins
  2. JENKINS-41668

No way to specify directory for dockerfile

    XMLWordPrintable

    Details

    • Similar Issues:

      Description

      It looks like there is no way to specify a directory to build an image using the "dockerfile" option. It only supports "filename", which is analogous to "-f" for the "docker build" command-line, but "docker build" takes as a required argument the DIRECTORY. This is necessary if you don't want the docker daemon to copy the whole repository when making the image, and you want instead to export just a small subset of files. Maybe adding something like "build_args" could be more flexible.

        Attachments

          Issue Links

            Activity

            Hide
            lucasocio Leandro Lucarella added a comment -

            For example, for a very simple project with a Dockerfile in docker/:
            docker build -t test -f docker/Dockerfile . -> Sending build context to Docker daemon 9.861 MB
            docker build -t test -f docker/Dockerfile docker -> Sending build context to Docker daemon 2.048 kB

            Sending ~10MB vs sending 2KB.

            I really hope this issue gets addressed soon because it blocking us from using declarative pipelines as all our projects use this trick to avoid so much copying to the docker daemon...

            Show
            lucasocio Leandro Lucarella added a comment - For example, for a very simple project with a Dockerfile in docker/: docker build -t test -f docker/Dockerfile . -> Sending build context to Docker daemon 9.861 MB docker build -t test -f docker/Dockerfile docker -> Sending build context to Docker daemon 2.048 kB Sending ~10MB vs sending 2KB. I really hope this issue gets addressed soon because it blocking us from using declarative pipelines as all our projects use this trick to avoid so much copying to the docker daemon...
            Hide
            jamesdumay James Dumay added a comment -
            Show
            jamesdumay James Dumay added a comment - This pain point showed up on the user list https://groups.google.com/forum/m/#!topic/jenkinsci-users/NnX_PviNY2A
            Show
            abayer Andrew Bayer added a comment - Initial PR up at https://github.com/jenkinsci/pipeline-model-definition-plugin/pull/107
            Hide
            lucasocio Leandro Lucarella added a comment -

            Thanks a lot for the quick response. I found a workaround though, I can use a `.dockerignore` file with:

            *
            !docker/
            

            That would make the image building process to ignore everything outside the docker directory, which is what I wanted.

            Nevertheless, I think is a good feature to have in pipeline models, specially a `build_args` option since it makes it as flexible and future-proof as it can get.

            Show
            lucasocio Leandro Lucarella added a comment - Thanks a lot for the quick response. I found a workaround though, I can use a `.dockerignore` file with: * !docker/ That would make the image building process to ignore everything outside the docker directory, which is what I wanted. Nevertheless, I think is a good feature to have in pipeline models, specially a `build_args` option since it makes it as flexible and future-proof as it can get.
            Hide
            scm_issue_link SCM/JIRA link daemon added a comment -

            Code changed in jenkins
            User: Andrew Bayer
            Path:
            pipeline-model-definition/src/main/java/org/jenkinsci/plugins/pipeline/modeldefinition/agent/impl/DockerPipelineFromDockerfile.java
            pipeline-model-definition/src/main/resources/org/jenkinsci/plugins/pipeline/modeldefinition/agent/impl/DockerPipelineFromDockerfileScript.groovy
            pipeline-model-definition/src/test/java/org/jenkinsci/plugins/pipeline/modeldefinition/AgentTest.java
            pipeline-model-definition/src/test/resources/fromDockerfileInOtherDir.groovy
            http://jenkins-ci.org/commit/pipeline-model-definition-plugin/d8d42f135382a5fe5535005d49467d773daefe82
            Log:
            [FIXED JENKINS-41668] Add "dir" option for Dockerfile.

            Show
            scm_issue_link SCM/JIRA link daemon added a comment - Code changed in jenkins User: Andrew Bayer Path: pipeline-model-definition/src/main/java/org/jenkinsci/plugins/pipeline/modeldefinition/agent/impl/DockerPipelineFromDockerfile.java pipeline-model-definition/src/main/resources/org/jenkinsci/plugins/pipeline/modeldefinition/agent/impl/DockerPipelineFromDockerfileScript.groovy pipeline-model-definition/src/test/java/org/jenkinsci/plugins/pipeline/modeldefinition/AgentTest.java pipeline-model-definition/src/test/resources/fromDockerfileInOtherDir.groovy http://jenkins-ci.org/commit/pipeline-model-definition-plugin/d8d42f135382a5fe5535005d49467d773daefe82 Log: [FIXED JENKINS-41668] Add "dir" option for Dockerfile.
            Hide
            scm_issue_link SCM/JIRA link daemon added a comment -

            Code changed in jenkins
            User: Andrew Bayer
            Path:
            pipeline-model-definition/src/main/groovy/org/jenkinsci/plugins/pipeline/modeldefinition/validator/ModelValidatorImpl.groovy
            pipeline-model-definition/src/main/java/org/jenkinsci/plugins/pipeline/modeldefinition/agent/impl/DockerPipelineFromDockerfile.java
            pipeline-model-definition/src/main/resources/org/jenkinsci/plugins/pipeline/modeldefinition/Messages.properties
            pipeline-model-definition/src/main/resources/org/jenkinsci/plugins/pipeline/modeldefinition/agent/impl/DockerPipelineFromDockerfileScript.groovy
            pipeline-model-definition/src/test/java/org/jenkinsci/plugins/pipeline/modeldefinition/AgentTest.java
            pipeline-model-definition/src/test/java/org/jenkinsci/plugins/pipeline/modeldefinition/ValidatorTest.java
            pipeline-model-definition/src/test/resources/errors/dirSepInDockerfileName.groovy
            pipeline-model-definition/src/test/resources/fromDockerfileInOtherDir.groovy
            http://jenkins-ci.org/commit/pipeline-model-definition-plugin/3aa4358e5d5369d2d01282d5add5934ab5a5a835
            Log:
            Merge pull request #107 from abayer/jenkins-41668

            [FIXED JENKINS-41668] Add "dir" option for Dockerfile.

            Show
            scm_issue_link SCM/JIRA link daemon added a comment - Code changed in jenkins User: Andrew Bayer Path: pipeline-model-definition/src/main/groovy/org/jenkinsci/plugins/pipeline/modeldefinition/validator/ModelValidatorImpl.groovy pipeline-model-definition/src/main/java/org/jenkinsci/plugins/pipeline/modeldefinition/agent/impl/DockerPipelineFromDockerfile.java pipeline-model-definition/src/main/resources/org/jenkinsci/plugins/pipeline/modeldefinition/Messages.properties pipeline-model-definition/src/main/resources/org/jenkinsci/plugins/pipeline/modeldefinition/agent/impl/DockerPipelineFromDockerfileScript.groovy pipeline-model-definition/src/test/java/org/jenkinsci/plugins/pipeline/modeldefinition/AgentTest.java pipeline-model-definition/src/test/java/org/jenkinsci/plugins/pipeline/modeldefinition/ValidatorTest.java pipeline-model-definition/src/test/resources/errors/dirSepInDockerfileName.groovy pipeline-model-definition/src/test/resources/fromDockerfileInOtherDir.groovy http://jenkins-ci.org/commit/pipeline-model-definition-plugin/3aa4358e5d5369d2d01282d5add5934ab5a5a835 Log: Merge pull request #107 from abayer/jenkins-41668 [FIXED JENKINS-41668] Add "dir" option for Dockerfile.
            Hide
            scm_issue_link SCM/JIRA link daemon added a comment -

            Code changed in jenkins
            User: Andrew Bayer
            Path:
            content/doc/book/pipeline/syntax.adoc
            http://jenkins-ci.org/commit/jenkins.io/b13440af19a0a9ef115bb3316b361c3a6b9512fc
            Log:
            JENKINS-41668 Add "dir" option for Dockerfile declarative agent

            Depends on
            https://github.com/jenkinsci/pipeline-model-definition-plugin/pull/107
            being merged and released.

            Show
            scm_issue_link SCM/JIRA link daemon added a comment - Code changed in jenkins User: Andrew Bayer Path: content/doc/book/pipeline/syntax.adoc http://jenkins-ci.org/commit/jenkins.io/b13440af19a0a9ef115bb3316b361c3a6b9512fc Log: JENKINS-41668 Add "dir" option for Dockerfile declarative agent Depends on https://github.com/jenkinsci/pipeline-model-definition-plugin/pull/107 being merged and released.
            Hide
            scm_issue_link SCM/JIRA link daemon added a comment -

            Code changed in jenkins
            User: R. Tyler Croy
            Path:
            content/doc/book/pipeline/syntax.adoc
            http://jenkins-ci.org/commit/jenkins.io/29bf87e69645098f5f2a072e41a39c45eff6eb39
            Log:
            Merge pull request #588 from abayer/jenkins-41668

            JENKINS-41668 Add "dir" option for Dockerfile declarative agent

            Compare: https://github.com/jenkins-infra/jenkins.io/compare/8fa807c2ac6e...29bf87e69645

            Show
            scm_issue_link SCM/JIRA link daemon added a comment - Code changed in jenkins User: R. Tyler Croy Path: content/doc/book/pipeline/syntax.adoc http://jenkins-ci.org/commit/jenkins.io/29bf87e69645098f5f2a072e41a39c45eff6eb39 Log: Merge pull request #588 from abayer/jenkins-41668 JENKINS-41668 Add "dir" option for Dockerfile declarative agent Compare: https://github.com/jenkins-infra/jenkins.io/compare/8fa807c2ac6e...29bf87e69645

              People

              • Assignee:
                abayer Andrew Bayer
                Reporter:
                lucasocio Leandro Lucarella
              • Votes:
                1 Vote for this issue
                Watchers:
                5 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: