fix(build): pass git info via Docker build args (unblock main pipeline)

This commit is contained in:
Александр Зимин
2026-05-10 17:10:45 +00:00
parent 6a6441d169
commit d740092d0c
2 changed files with 26 additions and 1 deletions
+9
View File
@@ -211,9 +211,18 @@ build-docs:
# to registry" на manifest push.
# Когда Nexus blob storage стабилизируется, --no-cache можно убрать —
# добавляет ~2 минуты per service на полную пересборку.
# Git info passed как build args чтобы Spring Boot build-info goal получил
# реальные значения (внутри Docker context .git/ исключён через .dockerignore,
# git-commit-id-maven-plugin не может прочесть). Backend Dockerfile'ы
# используют эти ARG'и в `mvn -Dgit.commit.id.abbrev=... -Dgit.branch=...`.
# Frontend / docs / migrations Dockerfile'ы их игнорируют (no-op в context'е).
docker build --pull --no-cache -f "$DOCKERFILE" \
-t "$IMG:$IMAGE_TAG" -t "$IMG:latest" -t "$IMG:$CI_COMMIT_REF_SLUG" \
--build-arg BUILDKIT_INLINE_CACHE=1 \
--build-arg GIT_COMMIT="${CI_COMMIT_SHORT_SHA:-unknown}" \
--build-arg GIT_BRANCH="${CI_COMMIT_REF_NAME:-unknown}" \
--build-arg GIT_TAG="${CI_COMMIT_TAG:-none}" \
--build-arg GIT_TIME="${CI_COMMIT_TIMESTAMP:-unknown}" \
"$BUILD_CONTEXT"
docker push "$IMG:$IMAGE_TAG"
docker push "$IMG:latest"
+17 -1
View File
@@ -9,9 +9,25 @@
# .dockerignore исключает frontend (admin-ui), bench, docs, target/, .git/,
# IDE metadata — backend image остаётся компактным.
FROM repo.nstart.cloud/library/maven:3.9.9-eclipse-temurin-21 AS build
# Git info из CI environment (`.gitlab-ci.yml` `--build-arg`) — нужен для
# Spring Boot build-info goal через ordinis-app/pom.xml. Внутри Docker
# context .git/ исключён (.dockerignore), поэтому git-commit-id-maven-plugin
# не может прочитать локально. Defaults в pom.xml gracefully fallback'ят
# если ARG'и не переданы (local docker build без ENV).
ARG GIT_COMMIT=unknown
ARG GIT_BRANCH=unknown
# GIT_TAG defaults to "none" (не пусто): Maven property substitution трактует
# empty value как null → Spring Boot build-info goal валится с
# "Additional property 'tag' is illegal as its value is null".
ARG GIT_TAG=none
ARG GIT_TIME=unknown
WORKDIR /build
COPY . ./
RUN mvn -B -pl ordinis-app -am package -DskipTests
RUN mvn -B -pl ordinis-app -am package -DskipTests \
-Dgit.commit.id.abbrev="$GIT_COMMIT" \
-Dgit.branch="$GIT_BRANCH" \
-Dgit.tags="$GIT_TAG" \
-Dgit.commit.time="$GIT_TIME"
FROM repo.nstart.cloud/library/eclipse-temurin:21-jre
WORKDIR /app