-
Suggestion
-
Resolution: Duplicate
-
None
-
0
-
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.
- duplicates
-
BAM-17097 Docker task does not allow for custom named Dockerfile
- Closed
[BAM-20141] Specify Dockerfile location in Docker Build Image Tasks
Workflow | Original: JAC Suggestion Workflow [ 3019230 ] | New: JAC Suggestion Workflow 3 [ 3611335 ] |
Status | Original: RESOLVED [ 5 ] | New: Closed [ 6 ] |
Resolution | New: Duplicate [ 3 ] | |
Status | Original: Gathering Interest [ 11772 ] | New: Resolved [ 5 ] |
UIS | New: 0 |
Workflow | Original: Confluence Workflow - Public Facing v4 [ 2967388 ] | New: JAC Suggestion Workflow [ 3019230 ] |
Labels | New: affects-server |
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. |
Priority | Original: Low [ 4 ] | New: Medium [ 3 ] |
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.