-
Notifications
You must be signed in to change notification settings - Fork 401
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
CGO_ENABLED=0 breaks go-sqlite3, Error : Binary was compiled with 'CGO_ENABLED=0', go-sqlite3 requires cgo to work #52
Comments
We could tackle this in a couple ways... We could check for This would allow you to build a specific image with:
That would be a simple change here. Unfortunately, this would be global for your invocation of Or, we could expand the config file to allow build flags and environment variables to be configured in on a per-package basis. This is similar to how we allow overriding the base image: https://github.com/google/ko#overriding-the-base-for-particular-imports Something like this: baseImageOverrides:
github.com/my-org/my-repo/path/to/binary: docker.io/another/base:latest
buildOverrides:
github.com/my-org/my-repo/path/to/binary:
env:
- name: CGO_ENABLED
value: 1
flags:
- name: ldflags
value: "-X main.Version=foo" I don't love either of these solutions, but I also don't think it's reasonable for us to just not work with packages that require cgo... also open to other solutions I'm not seeing :) |
i think second option is more appropriate way to support fine graded controle. |
switching the order, let user provide any custom environment variables or overwrite. will this work ? cmd.Env = append(os.Environ(), "CGO_ENABLED=0", "GOOS=linux") to cmd.Env = append([]string{"CGO_ENABLED=0", "GOOS=linux"}, os.Environ()...) |
That seems reasonable to me |
thanks. can i send a PR? |
eventually we can further support customization for baseImageOverrides:
github.com/my-org/my-repo/path/to/binary: docker.io/another/base:latest
buildOverrides:
github.com/my-org/my-repo/path/to/binary:
env:
- name: CGO_ENABLED
value: 1
flags:
- name: ldflags
value: "-X main.Version=foo"
data:
- source: "config/template"
destination: "template"
- source: "config/seed"
destination: "data/seed"
|
Changing the order of environment variables so that user supplied value for `CGO_ENABLED` take priority #52
Fixed by #56 |
also tried
defaultBaseImage: gcr.io/distroless/base
without any luckTest : repo to reproduce https://github.com/xmlking/micro-starter-kit
Error
panic: could not build 'user-repository' because the build function panicked: could not build 'database': Binary was compiled with 'CGO_ENABLED=0', go-sqlite3 requires cgo to work. This is a stub
The text was updated successfully, but these errors were encountered: