diff --git a/Dockerfile b/Dockerfile index 6f9c86d9..ec8d8a61 100644 --- a/Dockerfile +++ b/Dockerfile @@ -25,8 +25,16 @@ COPY --chown=gen3:gen3 ./deployment/wsgi/wsgi.py /${appname}/wsgi.py # install the app RUN poetry install --without dev --no-interaction -RUN git config --global --add safe.directory ${appname} && COMMIT=`git rev-parse HEAD` && echo "COMMIT=\"${COMMIT}\"" > ${appname}/version_data.py \ - && VERSION=`git describe --always --tags` && echo "VERSION=\"${VERSION}\"" >> ${appname}/version_data.py +RUN echo "Latest tags (sorted by date):" && git tag --contains HEAD --sort=-taggerdate +RUN echo "Git describe tags:" && git describe --always --tags +RUN VERSION=$(git tag --contains HEAD --sort=-taggerdate | head -n 1) && if [ -z "$VERSION" ]; then \ + echo "Tag command failed or returned empty. Falling back to git describe."; \ + VERSION=$(git describe --always --tags); \ + echo "Using git describe VERSION: $VERSION"; \ + else \ + echo "Successfully found tag, VERSION: $VERSION"; \ + fi && git config --global --add safe.directory ${appname} && COMMIT=`git rev-parse HEAD` && echo "COMMIT=\"${COMMIT}\"" > ${appname}/version_data.py \ + && echo "VERSION=\"${VERSION}\"" >> ${appname}/version_data.py # Final stage FROM base