Skip to content

Commit

Permalink
core: Dockerfile: Enforce style for git version
Browse files Browse the repository at this point in the history
Signed-off-by: Patrick José Pereira <patrickelectric@gmail.com>
  • Loading branch information
patrickelectric committed Apr 26, 2024
1 parent 8dfd61c commit f6db7b1
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions core/Dockerfile
Expand Up @@ -24,6 +24,17 @@ FROM bluerobotics/blueos-base:v0.1.1
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
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: <TAG>-<COMMIT_NUMBER>-g<SHORT_HASH>)" \
&& exit 1 || exit 0

# Set these arguments as environment variables
ENV TARGETARCH=${TARGETARCH}
ENV TARGETVARIANT=${TARGETVARIANT}
Expand Down Expand Up @@ -66,12 +77,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 \
Expand Down

0 comments on commit f6db7b1

Please sign in to comment.