diff --git a/core/Dockerfile b/core/Dockerfile index e92070ad9..4c2a64ba4 100644 --- a/core/Dockerfile +++ b/core/Dockerfile @@ -2,6 +2,7 @@ FROM --platform=$BUILDPLATFORM oven/bun:1.0.3-slim AS frontendBuilder ARG VITE_APP_GIT_DESCRIBE +ENV VITE_APP_GIT_DESCRIBE=${VITE_APP_GIT_DESCRIBE:-none/none-0-g00000000} RUN [ -z "$VITE_APP_GIT_DESCRIBE" ] \ && echo "VITE_APP_GIT_DESCRIBE argument not provided." \ && echo "Use: --build-arg VITE_APP_GIT_DESCRIBE=\$(git describe --long --always --dirty --all)" \ @@ -24,6 +25,18 @@ FROM bluerobotics/blueos-base:v0.1.0 ARG TARGETARCH ARG TARGETVARIANT +# Ensure that the git describe exists and also is in valid format as well +# The format can be invalid if someone is build BlueOS without a tag as reference +ARG GIT_DESCRIBE_TAGS +ENV GIT_DESCRIBE_TAGS=${GIT_DESCRIBE_TAGS:-0.0.0-0-g00000000} +RUN [ -z "$GIT_DESCRIBE_TAGS" ] \ + && echo "GIT_DESCRIBE_TAGS argument not provided." \ + && echo "Use: --build-arg GIT_DESCRIBE_TAGS=\$(git describe --tags --long --always)" \ + && exit 1 \ + || /bin/bash -c "[[ ! $GIT_DESCRIBE_TAGS =~ -[0-9]+-g[a-f0-9]{8}$ ]]" \ + && echo "Invalid format: $GIT_DESCRIBE_TAGS (E.g: --g)" \ + && exit 1 || exit 0 + # Set these arguments as environment variables ENV TARGETARCH=${TARGETARCH} ENV TARGETVARIANT=${TARGETVARIANT} @@ -66,12 +79,6 @@ COPY --from=frontendBuilder /home/pi/frontend/dist /home/pi/frontend ## If the folder tree contains any files during the build step, it means we put it here by mistake. RUN [ -z "$(find '/root/.config' -mindepth 1 -type f)" ] -ARG GIT_DESCRIBE_TAGS -RUN [ -z "$GIT_DESCRIBE_TAGS" ] \ - && echo "GIT_DESCRIBE_TAGS argument not provided." \ - && echo "Use: --build-arg GIT_DESCRIBE_TAGS=\$(git describe --tags --long --always)" \ - && exit 1 || exit 0 - # Update blueosrc with the necessary environment variables RUN RCFILE_PATH="/etc/blueosrc" \ && echo "export GIT_DESCRIBE_TAGS=$GIT_DESCRIBE_TAGS" >> $RCFILE_PATH \