Closed shahzzzam closed 1 year ago
@chloeyin can you check if the issue is till reproed?
It is still reproduced.
This is a context
tree
.
├── CHANGELOG.md
├── CONTRIBUTING.md
├── Dockerfile
├── Dockerfile-app
├── Dockerfile-base
├── LICENSE.md
├── README.md
├── package.json
├── server.js
├── subfolder
│ └── subfolder2
│ ├── Dockerfile
│ ├── subfolder3
│ │ ├── Dockerfile-subfolder
│ │ └── taskmulti-2.yaml
│ └── taskmulti_inner.yaml
├── taskmulti-multiregistry.yaml
└── taskmulti.yaml
If using subfolder/subfolder2/subfolder3/taskmulti-2.yaml
as a task file
version: v1.0.0
steps:
# Build target image
- build: -f Dockerfile-subfolder .
az acr task create -n $task-r $registry -c $GitContext \
-f subfolder/subfolder2/subfolder3/taskmulti-2.yaml \
--base-image-trigger-enabled false --commit-trigger-enabled false
az acr task run -n $task-r $registry
Queued a run with ID: cd3h
Waiting for an agent...
2023/02/20 04:46:15 Downloading source code...
2023/02/20 04:46:16 Finished downloading source code
2023/02/20 04:46:17 Creating Docker network: acb_default_network, driver: 'bridge'
2023/02/20 04:46:17 Successfully set up Docker network: acb_default_network
2023/02/20 04:46:17 Setting up Docker configuration...
2023/02/20 04:46:17 Successfully set up Docker configuration
2023/02/20 04:46:17 Logging in to registry: yzhregistry.azurecr.io
2023/02/20 04:46:18 Successfully logged into yzhregistry.azurecr.io
2023/02/20 04:46:18 Executing step ID: acb_step_0. Timeout(sec): 600, Working directory: '', Network: 'acb_default_network'
2023/02/20 04:46:18 Scanning for dependencies...
2023/02/20 04:46:19 Output from dependency scanning: error opening dockerfile: Dockerfile-subfolder, error: open Dockerfile-subfolder: no such file or directory
failed to run step ID: acb_step_0: failed to scan dependencies: exit status 1
Run ID: cd3h failed after 5s. Error: failed during run, err: exit status 1
Run failed
So the acb cannot find the docker file in this case. But if you set the working directory to the path relative to the root, it will work.
version: v1.0.0
steps:
# Build target image
- build: -f Dockerfile-subfolder .
workingDirectory: subfolder/subfolder2/subfolder3
From the code, it will not use the path relative to the location of the task file. https://github.com/Azure/acr-builder/blob/7470945443e0c1e69b09147ec8a63d51af051f8a/builder/builder.go#L292-L313
Thanks for the investigation. So the path is based on the context. We can set up the workingDirectory to the child folder as needed.
Is this a BUG REPORT or FEATURE REQUEST?: bug report What happened?: If you have a task file located in subfolder, and it has a build command. Then we need to set the working-dir of the docker build command up until the downloaded context correctly.
For instance if task is located in /workspace/foo/bar
And build context is remote. Then it should be downloaded under
/bar
. So, /workspace/foo/bar/my_acb_step_0/my-repoAnd workDir for docker build should be:
/workspace/foo/bar/my_acb_step_0
What did you expect to happen?:
How do you reproduce it (as minimally and precisely as possible)?:
Environment:
Anything else we need to know?: