Skip to content

Feature Request: Ability to specify working-directory #65

@sfgeorge

Description

@sfgeorge

Behaviour

tl;dr I can get docker buildx bake to succeed only when I cd to the subdirectory where docker-compose.yml. Can I similarly invoke a change of working directory with bake-action?

By having the ability to change the working directory, one would have a suitable workaround to the following issue in buildx

docker/buildx#1028

Steps to reproduce this issue

Given the following project directory structure:

tests/docker-compose.yml
tests/dockerfiles/debian8/Dockerfile
tests/dockerfiles/debian9/Dockerfile
tests/dockerfiles/debian10/Dockerfile

And the following workflow:

name: CI
on:
  push:
  pull_request:

jobs:
  tests:

    runs-on: ubuntu-latest

    defaults:
      run:
        working-directory: tests

    steps:
      - uses: actions/checkout@v3

      - name: Build
        uses: docker/bake-action@v1.7.0
        with:
          files: tests/docker-compose.yml

And the following tests/docker-compose.yml file

version: "3"
services:
  debian8:
    build: ./dockerfiles/debian8
    cap_add: [ALL]
  debian9:
    build: ./dockerfiles/debian9
    cap_add: [ALL]
  debian10:
    build: ./dockerfiles/debian10
    cap_add: [ALL]

When a build definition file is specified in a subdirectory of the project such as above

Then resolution of Dockerfiles fails.

This is an issue with docker buildx bake itself, not bake-action:

docker buildx bake -f  tests/docker-compose.yml
[+] Building 0.0s (0/0)
error: unable to prepare context: path "dockerfiles/debian9" not found

However, with docker buildx bake there is at least a workaround – Simply first change the working directory to be that of where the build definition file exists.

cd tests && docker buildx bake
cd tests && docker buildx bake
[+] Building 1.4s (23/23) FINISHED
# (output omitted)

Expected behaviour

bake-action should allow one to control the current working directory from which docker buildx bake is invoked.

Configuration

Logs

Download the log file of your build
and attach it to this issue.

logs_28.zip

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions