Skip to content

Commit

Permalink
Dockerfile and binary changes to accommodate vendor or no vendor (#320)
Browse files Browse the repository at this point in the history
Dockerfile and binary changes to accommodate vendor or no vendor
  • Loading branch information
janelletavares authored Apr 18, 2022
1 parent d6ce5ea commit bb837f7
Show file tree
Hide file tree
Showing 7 changed files with 24 additions and 17 deletions.
17 changes: 16 additions & 1 deletion cmd/meroxa/turbine_cli/golang/build.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package turbinego
import (
"context"
"fmt"
"os"
"os/exec"

"github.com/meroxa/cli/log"
Expand All @@ -24,5 +25,19 @@ func BuildBinary(ctx context.Context, l log.Logger, appPath, appName string, pla
l.Errorf(ctx, "%s", string(stdout))
return fmt.Errorf("build failed")
}
return err
return buildForCrossCompile(ctx, l, appPath, appName)
}

func buildForCrossCompile(ctx context.Context, l log.Logger, appPath, appName string) error {
cmd := exec.Command("go", "build", "--tags", "platform", "-o", appName+".cross", "./...") //nolint:gosec
cmd.Env = os.Environ()
cmd.Env = append(cmd.Env, "CGO_ENABLED=0", "GOOS=linux", "GOARCH=amd64")
cmd.Dir = appPath

stdout, err := cmd.CombinedOutput()
if err != nil {
l.Errorf(ctx, "%s", string(stdout))
return fmt.Errorf("cross compile failed")
}
return nil
}
2 changes: 1 addition & 1 deletion cmd/meroxa/turbine_cli/local_deployment.go
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ func (ld *LocalDeploy) buildImage(ctx context.Context, l log.Logger, pwd, imageN
}
dockerBuildOutput := buf.String()

re := regexp.MustCompile(`{"errorDetail":{"message":"([^"]+)"}`)
re := regexp.MustCompile(`{"errorDetail":{[^}]*"message":"([^"]+)"}`)
matches := re.FindAllStringSubmatch(dockerBuildOutput, -1)
if len(matches) != 0 {
const subMatchArraySize = 2
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ require (
github.com/briandowns/spinner v1.18.1
github.com/docker/docker v20.10.12+incompatible
github.com/mattn/go-shellwords v1.0.12
github.com/meroxa/turbine-go v0.0.0-20220415203703-5ab9fcaf547d
github.com/meroxa/turbine-go v0.0.0-20220418141359-a37ec2862d9a
github.com/volatiletech/null/v8 v8.1.2
)

Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -576,8 +576,8 @@ github.com/meroxa/funtime v0.0.0-20220113012133-85e6e898fc73/go.mod h1:K2y2GvcA4
github.com/meroxa/meroxa-go v0.0.0-20220208195203-71ddc3133fab/go.mod h1:HDFszURCM1cOpKE699o5Hs0T2tEIXqY+vFcsur3RiwY=
github.com/meroxa/meroxa-go v0.0.0-20220415221139-f31436f83dca h1:HTg9REXt9NqbX2syACtpUEwF/unzwWRjG9AkSaqcnLc=
github.com/meroxa/meroxa-go v0.0.0-20220415221139-f31436f83dca/go.mod h1:BsqYa9jqfyGOAgfkggfK567b2Ahkb+RCH3lXDQGgrh8=
github.com/meroxa/turbine-go v0.0.0-20220415203703-5ab9fcaf547d h1:JWJ0rrFmm9zV3WMMm3hIXS0Ebegm129SVs3zPcFi2Kk=
github.com/meroxa/turbine-go v0.0.0-20220415203703-5ab9fcaf547d/go.mod h1:F4ODyjX+tn5dYFRc1bQlHLUnTtlJIxs09AKHqfCD5Cg=
github.com/meroxa/turbine-go v0.0.0-20220418141359-a37ec2862d9a h1:wcfOhNkl719CrPe8OmgiZInm448enMDrOwr/pBy5/7w=
github.com/meroxa/turbine-go v0.0.0-20220418141359-a37ec2862d9a/go.mod h1:F4ODyjX+tn5dYFRc1bQlHLUnTtlJIxs09AKHqfCD5Cg=
github.com/miekg/dns v1.0.14/go.mod h1:W1PPwlIAgtquWBMBEV9nkV9Cazfe8ScdGz/Lj7v3Nrg=
github.com/miekg/pkcs11 v1.0.3/go.mod h1:XsNlhZGX73bx86s2hdc/FuaLm2CPZJemRLMA+WTFxgs=
github.com/mistifyio/go-zfs v2.1.2-0.20190413222219-f784269be439+incompatible/go.mod h1:8AuVvqP/mXw1px98n46wfvcGfQ4ci2FwoAjKYxuo3Z4=
Expand Down
12 changes: 2 additions & 10 deletions vendor/github.com/meroxa/turbine-go/deploy/template/Dockerfile

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion vendor/github.com/meroxa/turbine-go/init/template/app.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion vendor/modules.txt
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ github.com/mattn/go-shellwords
## explicit; go 1.17
github.com/meroxa/meroxa-go/pkg/meroxa
github.com/meroxa/meroxa-go/pkg/mock
# github.com/meroxa/turbine-go v0.0.0-20220415203703-5ab9fcaf547d
# github.com/meroxa/turbine-go v0.0.0-20220418141359-a37ec2862d9a
## explicit; go 1.17
github.com/meroxa/turbine-go/deploy
github.com/meroxa/turbine-go/init
Expand Down

0 comments on commit bb837f7

Please sign in to comment.