mirror of
https://github.com/qdrant/qdrant.git
synced 2026-07-23 11:11:00 -05:00
fix: Include git commit id while building docker image if possible (#3419)
* feat: Print commit id in dev container build workflow * fix: Keep .git while building Qdrant binary in docker * fix: Remove redundant printing of git commit id * fix: Copy only git files first * fix: Docker build should have commit id if present * refactor: Use fewer lines of code
This commit is contained in:
@@ -8,5 +8,4 @@ lib/collection/target
|
||||
lib/storage/target
|
||||
openapi/tests/
|
||||
*.tar
|
||||
.git
|
||||
.github/
|
||||
.github/
|
||||
|
||||
1
.github/workflows/dev-docker-image-build.yml
vendored
1
.github/workflows/dev-docker-image-build.yml
vendored
@@ -14,6 +14,7 @@ jobs:
|
||||
- uses: Swatinem/rust-cache@v2
|
||||
- name: Build the Docker image
|
||||
run: |
|
||||
|
||||
# Create build container
|
||||
docker run --rm --privileged multiarch/qemu-user-static --reset -p yes
|
||||
docker buildx create --use
|
||||
|
||||
@@ -62,7 +62,7 @@ RUN case "$BUILDPLATFORM" in \
|
||||
ARG TARGETPLATFORM
|
||||
ENV TARGETPLATFORM=${TARGETPLATFORM:-linux/amd64}
|
||||
|
||||
RUN xx-apt-get install -y pkg-config gcc g++ libc6-dev libunwind-dev
|
||||
RUN xx-apt-get install -y pkg-config gcc g++ libc6-dev libunwind-dev git
|
||||
|
||||
# Select Cargo profile (e.g., `release`, `dev` or `ci`)
|
||||
ARG PROFILE=release
|
||||
@@ -77,6 +77,7 @@ ARG RUSTFLAGS
|
||||
ARG LINKER=mold
|
||||
|
||||
COPY --from=planner /qdrant/recipe.json recipe.json
|
||||
COPY . .
|
||||
# `PKG_CONFIG=...` is a workaround for `xx-cargo` bug for crates based on `pkg-config`!
|
||||
#
|
||||
# https://github.com/tonistiigi/xx/issues/107
|
||||
|
||||
@@ -26,11 +26,11 @@ fn main() -> std::io::Result<()> {
|
||||
|
||||
// Fetch git commit ID and pass it to the compiler
|
||||
match Command::new("git").args(["rev-parse", "HEAD"]).output() {
|
||||
Ok(output) => {
|
||||
Ok(output) if output.status.success() => {
|
||||
let git_commit_id = str::from_utf8(&output.stdout).unwrap().trim();
|
||||
println!("cargo:rustc-env=GIT_COMMIT_ID={git_commit_id}");
|
||||
}
|
||||
Err(_) => println!("cargo:warning=current git commit hash could not be determined"),
|
||||
Ok(_) | Err(_) => println!("cargo:warning=current git commit hash could not be determined"),
|
||||
}
|
||||
|
||||
Ok(())
|
||||
|
||||
@@ -17,7 +17,9 @@ impl Default for VersionInfo {
|
||||
VersionInfo {
|
||||
title: "qdrant - vector search engine".to_string(),
|
||||
version: env!("CARGO_PKG_VERSION").to_string(),
|
||||
commit: option_env!("GIT_COMMIT_ID").map(ToString::to_string),
|
||||
commit: option_env!("GIT_COMMIT_ID")
|
||||
.map(ToString::to_string)
|
||||
.filter(|s| !s.trim().is_empty()),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user