-
Notifications
You must be signed in to change notification settings - Fork 706
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[docker] Enable image builds from a git worktree
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.
- Loading branch information
Showing
12 changed files
with
53 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
#!/usr/bin/env bash | ||
|
||
set -euo pipefail | ||
|
||
# Emits an image tag derived from the current branch or tag | ||
|
||
IMAGE_TAG="$( git symbolic-ref -q --short HEAD || git describe --tags --exact-match || true )" | ||
if [[ -z "${IMAGE_TAG}" ]]; then | ||
# Supply a default tag when one is not discovered | ||
IMAGE_TAG=ci_dummy | ||
elif [[ "${IMAGE_TAG}" == */* ]]; then | ||
# Slashes are not legal for docker image tags - replace with dashes | ||
IMAGE_TAG="$( echo "${IMAGE_TAG}" | tr '/' '-' )" | ||
fi | ||
echo "${IMAGE_TAG}" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
#!/usr/bin/env bash | ||
|
||
# Ignore warnings about variables appearing unused since this file is not the consumer of the variables it defines. | ||
# shellcheck disable=SC2034 | ||
|
||
set -euo pipefail | ||
|
||
AVALANCHE_PATH=$( cd "$( dirname "${BASH_SOURCE[0]}" )"; cd .. && pwd ) # Directory above this script | ||
|
||
# WARNING: this will use the most recent commit even if there are un-committed changes present | ||
git_commit="${AVALANCHEGO_COMMIT:-$(git --git-dir="${AVALANCHE_PATH}/.git" rev-parse HEAD)}" | ||
commit_hash="${git_commit::8}" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters