Skip to content

[docker] Enable image builds from git worktrees #3660

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

Merged
merged 4 commits into from
Jan 27, 2025

Conversation

marun
Copy link
Contributor

@marun marun commented Jan 19, 2025

Why this should be merged

This change enables docker image builds from git worktrees. This required discoverying the git commit used to configure the avalanchego build script in advance of image build and providing it as an argument to image build.

Previously, it was impossible to build docker images from a git worktree:

  • the avalanchego build script needed to discover the git commit to configure the binary with for traceability
  • the build script assumed a .git directory to discover the git commit
  • the dockerfile copied the working tree into the image prior to running the avalanchego build script
  • if the working tree was for a git worktree, the resulting copy wouldn't have a .git directory to discovery the git commit from
    • instead of a regular .git directory, a non-primary worktree has a .git file referencing a path in the primary worktree's .git directory.

How this was tested

CI

Need to be documented in RELEASES.md?

N/A

@marun marun added the testing This primarily focuses on testing label Jan 19, 2025
@marun marun self-assigned this Jan 19, 2025
@marun marun force-pushed the worktree-image-builds branch 5 times, most recently from 4573e47 to f32daa7 Compare January 19, 2025 05:30
@maru-ava maru-ava assigned maru-ava and unassigned marun Jan 22, 2025
This change enables docker image builds from [git
worktrees](https://git-scm.com/docs/git-worktree). This required
discoverying the git commit used to configure the avalanchego build
script in advance of image build and providing it as an argument to
image build.

Previously, it was impossible to build docker images from a git
worktree:

 - the avalanchego build script needed to discover the git commit to
 configure the binary with for traceability

 - the build script assumed a .git directory to discover the git
 commit

 - the dockerfile copied the working tree into the image prior to
 running the avalanchego build script

 - if the working tree was for a git worktree, the resulting copy
 wouldn't have a .git directory to discovery the git commit from

  - instead of a regular .git directory, a non-primary worktree has a
  .git file referencing a path in the primary worktree's .git
  directory.
@maru-ava maru-ava force-pushed the worktree-image-builds branch from 6c4b75e to e676c36 Compare January 24, 2025 21:08
@maru-ava maru-ava force-pushed the worktree-image-builds branch from 8fa265f to ec0e81c Compare January 24, 2025 21:12
Copy link
Contributor

@michaelkaplan13 michaelkaplan13 left a comment

Choose a reason for hiding this comment

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

TIL what git worktrees are. Confirmed the image builds work from a linked worktree on this branch (and saw the error when trying to build it from a worktree on master).

@StephenButtolph StephenButtolph added this pull request to the merge queue Jan 27, 2025
Merged via the queue into master with commit 5d474d6 Jan 27, 2025
26 of 43 checks passed
@StephenButtolph StephenButtolph deleted the worktree-image-builds branch January 27, 2025 16:00
tsachiherman pushed a commit that referenced this pull request Jan 29, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
testing This primarily focuses on testing
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

4 participants