Skip to content
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

Generate a static binary by disabling cgo #18

Closed

Conversation

deverton-godaddy
Copy link
Contributor

As part of the Go 1.20 release it seems like the default for CGO_ENABLED is no longer carried over from the tools. This leads to linking issues on systems that use different versions of glibc from what the base image uses. See golang/go#58550 for more details.

This change should fix #16

As part of the Go 1.20 release it seems like the default for `CGO_ENABLED` is no longer carried over from the tools. This leads to linking issues on systems that use different versions of glibc from what the base image uses. See golang/go#58550 for more details.

This change should fix cosmonic-labs#16
Use `scratch` as a base image since we're generating a static binary
anyway. Also be more explicity about the platform and target OS during
the build.
@netlify
Copy link

netlify bot commented Jul 6, 2023

Deploy Preview for netreap canceled.

Name Link
🔨 Latest commit ded61cc
🔍 Latest deploy log https://app.netlify.com/sites/netreap/deploys/64c071d7f968860008d66c91

@deverton-godaddy deverton-godaddy changed the title Fix amznlnx2 Generate a static binary by disabling cgo Jul 6, 2023
@p1u3o
Copy link

p1u3o commented Jul 15, 2023

This also fixes Netreap on Rocky Linux 9 and I presume all other RHEL-9 based distros.

deverton-godaddy and others added 4 commits July 20, 2023 16:18
DRAFT

With the release of Nomad 1.6 it's possible to get the network address
of the allocation from Nomad. The change to enable this is only in the
client library and does not require updating the Nomad server. The IP
was sent back by older Nomad versions, it just wasn't available in the
client.

This enables refactoring the endpoint reconcilliation to make use of the
IP address to identify the endpoint within Cilium.

There is no longer a dependency on Consul for policies.

Additional, endpoints are now labelled with the task group and task
information as services can be created at those levels.
Remove unused flags from the readme and command line and refactor the
code to allow for testing.
Refactor endpoint handling and reconcilliation.
@protochron
Copy link
Contributor

It looks like #21 supersedes this PR?

@protochron protochron self-requested a review July 31, 2023 13:39
Copy link
Contributor

@protochron protochron left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This only needs a few small changes related to the Dockerfile, but other than that it looks good to go to me!

Thanks a ton for the contribution and helping us remove the dependency on Consul!

FROM golang:1.20 as builder
WORKDIR /netreap
COPY . /netreap
FROM --platform=${BUILDPLATFORM} golang:1.20.5 as builder
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think you need the --platform argument since buildx takes care of that for you, at least in CI

ENTRYPOINT ["/usr/bin/netreap"]
ARG TARGETOS
ARG TARGETARCH
RUN CGO_ENABLED=0 GOOS=${TARGETOS} GOARCH=${TARGETARCH} go build -ldflags "-s -w -X 'main.Version=$VERSION'" -o /netreap
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You really don't need this if you're using buildx since the build happens in the correct platform image

ARG TARGETOS
ARG TARGETARCH
RUN CGO_ENABLED=0 GOOS=${TARGETOS} GOARCH=${TARGETARCH} go build -ldflags "-s -w -X 'main.Version=$VERSION'" -o /netreap
FROM scratch AS bin
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd prefer to stick with the distroless image since it comes with cacerts pre-installed. If you want to stick with a static build without CGO, you can switch to use gcr.io/distroless/static instead

@protochron
Copy link
Contributor

Ugh, realized I left review comments here instead of on #21. I'll copy them over to that one

@deverton-godaddy
Copy link
Contributor Author

Argh, sorry, looks like I stuffed up the branches for the PR. Let me close this one in favor of #21

@deverton-godaddy deverton-godaddy deleted the fix-amznlnx2 branch August 3, 2023 03:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[BUG] netreap 0.1.2 doesn't run on Amazon Linux 2.
3 participants