Uploaded image for project: 'Bamboo Data Center'
  1. Bamboo Data Center
  2. BAM-20141

Specify Dockerfile location in Docker Build Image Tasks

    • Icon: Suggestion Suggestion
    • Resolution: Duplicate
    • None
    • Docker
    • 0
    • Our product teams collect and evaluate feedback from a number of different sources. To learn more about how we use customer feedback in the planning process, check out our new feature policy.

      In some larger projects I have several Dockerfiles each in their own sub-directories in order to organise them rather than putting them in the root directory.

      Using a tool such as Docker Compose, I can specify the Dockerfile location and the build context separately when building Docker images.

      This seems to be impossible in Bamboo. If I change the working sub-directory in a Build a Docker Image task to say <project-directory>/docker/php then I can't now copy files across from <project-directory> to the image I'm building using the COPY command in the Dockerfile. I can of course move the Dockerfile in question to the root <project-directory> but then I'm now limiting myself to a "one Dockerfile per project" scenario.

      Here's an example of a docker-compose.yml file where I can be flexible with build context and dockerfile locations:

      version: '3'
      
      volumes:
          logs:
              driver: local
          dbdata:
      
      services:
          php:
              build:
                  context: .
                  dockerfile: docker/php/Dockerfile
              env_file: .env
              volumes:
                  - .:/usr/src/mail-exchange
                  - logs:/var/www/logs
              links:
                  - db
          nginx:
              build:
                  context: docker/nginx/.
              ports:
                  - 80:80
              volumes:
                  - .:/var/www
              links:
                - php
      

      The benefit here is that I can organise my Dockerfiles neatly and have multiple Dockerfiles in the same project. This is essential when these days it's quite command to have large applications running in Kubernetes with serveral images (PHP or Node.js, Redis, Nginx).

      My suggested solution would be to either integrate Docker Compose with Docker related tasks as some IDEs do. Alternatively we could specify the Dockerfile location for a Docker Image Build task.

            [BAM-20141] Specify Dockerfile location in Docker Build Image Tasks

            I'm late to reply here, but there is an option to supply docker build arguments in the Docker task (I am using Bamboo 7.0). With the -f flag you can specify the path from the context to your Dockerfile, i.e -f some_name.Dockerfile. That way you build different image names from the same repository.

            Patrick van Laar added a comment - I'm late to reply here, but there is an option to supply docker build arguments in the Docker task (I am using Bamboo 7.0). With the -f flag you can specify the path from the context to your Dockerfile, i.e -f some_name.Dockerfile. That way you build different image names from the same repository.
            Katherine Yabut made changes -
            Workflow Original: JAC Suggestion Workflow [ 3019230 ] New: JAC Suggestion Workflow 3 [ 3611335 ]
            Status Original: RESOLVED [ 5 ] New: Closed [ 6 ]
            Alexey Chystoprudov made changes -
            Resolution New: Duplicate [ 3 ]
            Status Original: Gathering Interest [ 11772 ] New: Resolved [ 5 ]
            Alexey Chystoprudov made changes -
            Link New: This issue duplicates BAM-17097 [ BAM-17097 ]

            I'm working on a set of golang projects in a single monorepository; each individual service is built using a Dockerfile that resides next to its "main.go" file in the directory structure.  With Bamboo unable to distinguish between Dockerfiles, I'm finding myself having to come up with a convoluted workaround that could be entirely avoided if this simple feature were to exist.

            Chris Browne added a comment - I'm working on a set of golang projects in a single monorepository; each individual service is built using a Dockerfile that resides next to its "main.go" file in the directory structure.  With Bamboo unable to distinguish between Dockerfiles, I'm finding myself having to come up with a convoluted workaround that could be entirely avoided if this simple feature were to exist.
            Krystian Brazulewicz made changes -
            UIS New: 0
            Owen made changes -
            Workflow Original: Confluence Workflow - Public Facing v4 [ 2967388 ] New: JAC Suggestion Workflow [ 3019230 ]
            Alvin Chevolleaux made changes -
            Labels New: affects-server
            Alvin Chevolleaux made changes -
            Description Original: In some larger projects I have several Dockerfiles each in their own sub-directories in order to organise them rather than putting them in the root directory.

            Using a tool such as Docker Compose, I can specify the Dockerfile location and the build context separately when building Docker images.

            This seems to be impossible in Bamboo. If I change the working sub-directory in a *Build a Docker Image* task to say <project-directory>/docker/php then I can't now copy files across from <project-directory> to the image I'm building using the COPY command in the Dockerfile. I can of course move the Dockerfile in question to the root <project-directory> but then I'm now limiting myself to a "one Dockerfile per project" scenario.

            Here's an example of a docker-compose.yml file where I can be flexible with build context and dockerfile locations:
            {code:java}
            version: '3'

            volumes:
                logs:
                    driver: local
                dbdata:

            services:
                php:
                    build:
                        context: .
                        dockerfile: docker/php/Dockerfile
                    env_file: .env
                    volumes:
                        - .:/usr/src/mail-exchange
                        - logs:/var/www/logs
                    links:
                        - db
                nginx:
                    build:
                        context: docker/nginx/.
                    ports:
                        - 80:80
                    volumes:
                        - .:/var/www
                    links:
                      - php
            {code}
            The benefit here is that I can organise my Dockerfiles neatly and have multiple Dockerfiles in the same project. This is essential when these days it's quite command to have large applications running in Kubernetes with serveral images (PHP or Node.js, Redis, Nginx).

            My suggested solution would be to either integrate Docker Compose with Docker related tasks as some IDEs do. Alternatively we could specify the Dockerfile location for a Docker Image Build task.

            If this feature is not implemented, it is perhaps worth suggesting to users to adopt a solution I used which is to create several VCS repositories per project, each containing its own Dockerfile. That way we can add a new plan configuration per Docker Image that we're building for a single project.
            New: In some larger projects I have several Dockerfiles each in their own sub-directories in order to organise them rather than putting them in the root directory.

            Using a tool such as Docker Compose, I can specify the Dockerfile location and the build context separately when building Docker images.

            This seems to be impossible in Bamboo. If I change the working sub-directory in a *Build a Docker Image* task to say <project-directory>/docker/php then I can't now copy files across from <project-directory> to the image I'm building using the COPY command in the Dockerfile. I can of course move the Dockerfile in question to the root <project-directory> but then I'm now limiting myself to a "one Dockerfile per project" scenario.

            Here's an example of a docker-compose.yml file where I can be flexible with build context and dockerfile locations:
            {code:java}
            version: '3'

            volumes:
                logs:
                    driver: local
                dbdata:

            services:
                php:
                    build:
                        context: .
                        dockerfile: docker/php/Dockerfile
                    env_file: .env
                    volumes:
                        - .:/usr/src/mail-exchange
                        - logs:/var/www/logs
                    links:
                        - db
                nginx:
                    build:
                        context: docker/nginx/.
                    ports:
                        - 80:80
                    volumes:
                        - .:/var/www
                    links:
                      - php
            {code}
            The benefit here is that I can organise my Dockerfiles neatly and have multiple Dockerfiles in the same project. This is essential when these days it's quite command to have large applications running in Kubernetes with serveral images (PHP or Node.js, Redis, Nginx).

            My suggested solution would be to either integrate Docker Compose with Docker related tasks as some IDEs do. Alternatively we could specify the Dockerfile location for a Docker Image Build task.
            Alvin Chevolleaux made changes -
            Priority Original: Low [ 4 ] New: Medium [ 3 ]

              Unassigned Unassigned
              cfbda3d3a0bf Alvin Chevolleaux
              Votes:
              8 Vote for this issue
              Watchers:
              5 Start watching this issue

                Created:
                Updated:
                Resolved: