From e3bc7880998cfcd7399296be9d61d0778f4a3275 Mon Sep 17 00:00:00 2001 From: "Peter A. Jonsson" Date: Sat, 11 May 2024 11:39:59 +0200 Subject: [PATCH] Dockerfile: fail on errors Rewrite the if-then-else into short-circuiting tests followed by commands chained together with &&. This makes building the image fail if something is wrong, instead of giving strange errors when running the tests. --- Dockerfile | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/Dockerfile b/Dockerfile index 7df7ec46f..0cf231c1b 100644 --- a/Dockerfile +++ b/Dockerfile @@ -61,12 +61,11 @@ COPY . $APPDIR COPY --from=builder --link /build/*.whl ./ RUN python3.10 -m pip --disable-pip-version-check -q install *.whl && \ rm *.whl && \ - if [ "$ENVIRONMENT" = "deployment" ] ; then\ - pip --no-cache-dir --disable-pip-version-check install .[$ENVIRONMENT]; \ - rm -rf /code/* /code/.git* ; \ - else \ - pip --disable-pip-version-check install --editable .[$ENVIRONMENT]; \ - fi && \ + ([ "$ENVIRONMENT" = "deployment" ] || \ + pip --disable-pip-version-check install --editable .[$ENVIRONMENT]) && \ + ([ "$ENVIRONMENT" != "deployment" ] || \ + (pip --no-cache-dir --disable-pip-version-check install .[$ENVIRONMENT] && \ + rm -rf /code/* /code/.git*)) && \ pip freeze && \ ([ "$ENVIRONMENT" != "deployment" ] || \ apt-get remove -y \