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

Add a dockerignore #1962

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open

Conversation

MrAlias
Copy link
Contributor

@MrAlias MrAlias commented Mar 7, 2025

Stop copying the whole project when building the auto docker image. This causes unrelated changes to the parts of the codebase to invalidate the docker cache

This also stops using the make utility to build the project. Doing so brings in many steps outside of building the target binary (i.e. linting and running go mod tidy). Instead, run the go commands that are needed directly.

@MrAlias MrAlias added this to the v0.22.0 milestone Mar 7, 2025
@MrAlias MrAlias marked this pull request as ready for review March 7, 2025 21:42
@MrAlias MrAlias requested a review from a team as a code owner March 7, 2025 21:42
Comment on lines +24 to +28
GOARCH=$TARGETARCH \
CGO_ENABLED=$CGO_ENABLED \
BPF2GO_CFLAGS=$BPF2GO_CFLAGS \
go generate ./... \
&& go build -o otel-go-instrumentation ./cli/...
Copy link
Contributor

@RonFed RonFed Mar 9, 2025

Choose a reason for hiding this comment

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

I think I prefer calling the makefile here,
The main reason being we don't need to duplicate the env vars setup and having a single source of truth for building.
If we want to avoid go-mod tidy and linting we can probably add a target without those dependencies?
Although I don't think it adds a lot of latency to the build (the go generate probably takes most of the time anyway)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I prefer we avoid the circular dependency of make calling this and then this calling make.

Copy link
Contributor

Choose a reason for hiding this comment

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

I think I agree with @RonFed, calling make build reduces the need to make sure changes are duplicated

Copy link
Contributor Author

@MrAlias MrAlias Mar 11, 2025

Choose a reason for hiding this comment

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

Adding a one-off target to the Makefile just to run these commands does not seem appropriate to me.

It is a one-off command that is only ever meant to be run by the Dockerfile. Why not just add the command to the Dockerfile?

Additionally, it is adding the command to a development tooling file, but it is not meant to be run by developers. What happens when we get an issue asking why the new make target fails because their repo was not correctly linted before-hand? That seems like a valid complaint. They are running developer tooling, its just they don't have the domain history of the project to know that this "one special target" isn't meant for them to run.

Running the make target also means that we will need to copy over the Makefile. This, again, will mean that unrelated changes to the repo (the Makefile) will invalidate the docker cache. This happens a lot in developement.

I don't see adding a new include directory to BPF2GO_CFLAGS in both the Makefile and the Dockerfile as a burden given how little this happens.

Copy link
Contributor

Choose a reason for hiding this comment

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

Calling make build from the dockerfile is common for the reasons Ron and I mentioned. But, this isn't a huge deal

Copy link
Contributor

Choose a reason for hiding this comment

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

Additionally, it is adding the command to a development tooling file, but it is not meant to be run by developers. What happens when we get an issue asking why the new make target fails because their repo was not correctly linted before-hand? That seems like a valid complaint. They are running developer tooling, its just they don't have the domain history of the project to know that this "one special target" isn't meant for them to run.

This can be addressed by improving the Makefile.
For example when the build target is triggered, it can check if it is running on linux, otherwise return an informative error.

Copy link
Contributor Author

@MrAlias MrAlias Mar 14, 2025

Choose a reason for hiding this comment

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

@RonFed I don't follow. I develop on a Linux system, why would I want it to succeed for me but not for a Mac dev?

Also, that wouldn't address the docker cache invalidation I am trying to address.

Comment on lines +24 to +28
GOARCH=$TARGETARCH \
CGO_ENABLED=$CGO_ENABLED \
BPF2GO_CFLAGS=$BPF2GO_CFLAGS \
go generate ./... \
&& go build -o otel-go-instrumentation ./cli/...
Copy link
Contributor

Choose a reason for hiding this comment

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

Calling make build from the dockerfile is common for the reasons Ron and I mentioned. But, this isn't a huge deal

Stop copying the whole project when building the auto docker image. This
causes unrelated changes to the parts of the codebase to invalidate the
docker cache

This also stops using the `make` utility to build the project. Doing so
brings in many steps outside of building the target binary (i.e.
linting and running `go mod tidy`). Instead, run the go commands that
are needed directly.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants