From d419fd0c03bf1c4da928a72aa107cbe454b934ca Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Wed, 23 Mar 2022 15:45:06 +0300 Subject: [PATCH] abort build if actual commit id differs from requested for image --- src/app/Dockerfile | 2 ++ src/app/build-prepare.sh | 12 +++++++++++- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/src/app/Dockerfile b/src/app/Dockerfile index 553e20b..d52d208 100644 --- a/src/app/Dockerfile +++ b/src/app/Dockerfile @@ -28,9 +28,11 @@ ADD build-prepare.sh ${SCRIPT_ROOT} ARG ORIGIN_REPO_MAIN=https://git.tt-rss.org/fox/tt-rss.git ARG ORIGIN_REPO_XACCEL=https://git.tt-rss.org/fox/ttrss-nginx-xaccel.git +ARG ORIGIN_COMMIT= ENV ORIGIN_REPO_MAIN=${ORIGIN_REPO_MAIN} ENV ORIGIN_REPO_XACCEL=${ORIGIN_REPO_XACCEL} +ENV ORIGIN_COMMIT=${ORIGIN_COMMIT} RUN sh -c ${SCRIPT_ROOT}/build-prepare.sh diff --git a/src/app/build-prepare.sh b/src/app/build-prepare.sh index 2af037c..7f20969 100755 --- a/src/app/build-prepare.sh +++ b/src/app/build-prepare.sh @@ -4,9 +4,19 @@ DST_DIR=/src/tt-rss mkdir -p $DST_DIR +echo requested commit: $ORIGIN_COMMIT + echo cloning $ORIGIN_REPO_MAIN to $DST_DIR... git clone --branch master --depth 1 $ORIGIN_REPO_MAIN $DST_DIR -echo built for: $(git --git-dir=$DST_DIR/.git --no-pager log --pretty='%H' -n1 HEAD) + +BUILD_COMMIT=$(git --git-dir=$DST_DIR/.git --no-pager log --pretty='%H' -n1 HEAD) + +echo built for: $BUILD_COMMIT + +if [ ! -z $ORIGIN_COMMIT -a "$ORIGIN_COMMIT" != "$BUILD_COMMIT" ]; then + echo actual build commit differs from requested commit, bailing out. + exit 1 +fi echo cloning $ORIGIN_REPO_XACCEL to $DST_DIR/plugins.local/nginx_xaccel... git clone --branch master --depth 1 $ORIGIN_REPO_XACCEL $DST_DIR/plugins.local/nginx_xaccel