Skip to content

go: document libc and ca-certificates.crt dependencies? #1

Closed

Description

@evanj

When applying the examples for the go builder to my project, I ran into two problems:

  1. By default, the binary depends on libc (some version of musl it seems?). This can be worked around by adding env: ["CGO_ENABLED=0"].
  2. If you make HTTPS connections, it needs /etc/ssl/certs/ca-certificates.crt for the trusted root certificates.

I think this is mostly a documentation oversight. I think it could be "solved" in any of the following ways:

  • Document these dependencies/limitations in go/README.md?
  • Recommend that people use the golang-project builder and not go. I think golang-project sets an alpine base image in the Dockerfile by default, which would avoid this.
  • Document the alpine base image that is used by the builder, so we could add it as the correct base instead of scratch?
  • Ship a minimal base image that includes the correct libc version and ca-certificates.crt in the correct location, so we could use that instead of alpine (probably overkill; this makes tiny binaries, but adds maintenance burden).
  • Add a working example that connects to https://www.google.com, since I think that runs into both these dependencies (for the resolver and to verify the HTTPS certificate).

Activity

  1. skelterjohn commented on Jan 13, 2017

    @skelterjohn
    Contributor

    Thanks for the feedback, evanj.

    I've already got something in the works for CGO_ENABLED=0, I'll try to roll that out soon.

    For the cert issue, I'm not sure how I can address that in the go builder, which only creates a binary which relies on its container to have certs.

    I like your suggestion about the example, I'll take care of it.

  2. evanj commented on Jan 13, 2017

    @evanj
    Author

    Fair point: Re: certificates: It is up to the user to configure their image correctly; I just wish it was somehow more obvious that the binary alone is not sufficient, that said: there are lots of guides about including it. Maybe an easy fix is to have the examples reference a more complete base image instead of scratch, so that if someone like me just copies an example and tries to use it, its more likely to work correctly? A user who wants to cut down their image size is then on their own (or can reference the various Internet guides about it).

    libc is more difficult: with the current container builder, its looking for some version of musl, and it isn't clear how to find the right one. Disabling cgo works, but is also not ideal: I have things that use sqlite, and it might be nice to use the cloud builder with them.

    Anyway, thanks, feel free to close this as you see fit.

  3. skelterjohn commented on Jan 18, 2017

    @skelterjohn
    Contributor

    Check out the changes just pushed and let me know what you think. They're live in production now.

    I'm also considering having a go:alpine and go:debian as separate builders - then we'd avoid the CGO_ENABLED=0 requirement and you could have your sqlite fun.

  4. evanj commented on Jan 18, 2017

    @evanj
    Author

    These are awesome fixes; thank you! Definitely above and beyond my suggestions. I love the https example. Thanks, I'm closing this issue (see git commit add2207 for future reference)

  5. skelterjohn commented on Jan 19, 2017

    @skelterjohn
    Contributor

    Heads up - we're going to stop setting CGO_ENABLED=0 and instead have a gcr.io/cloud-builders/go:alpine and gcr.io/cloud-builders/go:wheezy build step, with gcr.io/cloud-builders/go=gcr.io/cloud-builders/go:alpine as a default.

  6. added a commit that references this issue on Aug 6, 2020
  7. added a commit that references this issue on Oct 5, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions