Skip to content
This repository has been archived by the owner on Jan 8, 2024. It is now read-only.

Commit

Permalink
Merge pull request #539 from sharkyze/builtin/docker/builder/support-…
Browse files Browse the repository at this point in the history
…dockerfile-path

builtin/docker/builder: Add dockerfile variable to BuilderConfig
  • Loading branch information
mitchellh authored Oct 16, 2020
2 parents 6844c05 + 68526c3 commit 0c7f025
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion builtin/docker/builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"context"
"fmt"
"os"
"path"

"github.com/docker/cli/cli/command/image/build"
"github.com/docker/docker/api/types"
Expand Down Expand Up @@ -38,6 +39,9 @@ type BuilderConfig struct {

// Controls whether or not the image should be build with buildkit or docker v1
UseBuildKit bool `hcl:"buildkit,optional"`

// The name/path to the Dockerfile if it is not the root of the project
Dockerfile string `hcl:"dockerfile,optional"`
}

func (b *Builder) Documentation() (*docs.Documentation, error) {
Expand Down Expand Up @@ -110,7 +114,12 @@ func (b *Builder) Build(

cli.NegotiateAPIVersion(ctx)

contextDir, relDockerfile, err := build.GetContextFromLocalDir(src.Path, "")
dockerfile := b.config.Dockerfile
if dockerfile != "" {
dockerfile = path.Join(src.Path, dockerfile)
}

contextDir, relDockerfile, err := build.GetContextFromLocalDir(src.Path, dockerfile)
if err != nil {
return nil, status.Errorf(codes.FailedPrecondition, "unable to create Docker context: %s", err)
}
Expand Down

0 comments on commit 0c7f025

Please sign in to comment.