From 3ad8f34e3f12107e0c10d27345a81efa357013dd Mon Sep 17 00:00:00 2001 From: Andrii Ostapenko Date: Wed, 19 May 2021 00:37:03 -0500 Subject: [PATCH] Fix passing entrypoint as a build arg Neither ARG or ENV are not expandable in ENTRYPOINT, though since ENV is available at runtime, we can use it as a work-around here. Thus, before [0], ENTRYPOINT could be overridden using env by passing --env BINARY=../../../. Now previous default behavior is broken since we don't have ENTRYPOINT env var. This commit fixes default behavior and allows to modify it from build arg as was intended with [0]. [0] https://review.opendev.org/c/airship/airshipctl/+/791886 Change-Id: I115df039bc4f845d07f53f68fa3b716d86e8b3a9 Signed-off-by: Andrii Ostapenko --- Dockerfile | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/Dockerfile b/Dockerfile index 39663b07d..999728463 100644 --- a/Dockerfile +++ b/Dockerfile @@ -37,5 +37,10 @@ ARG BINARY=airshipctl ENV BINARY=${BINARY} COPY --from=builder /usr/src/airshipctl/bin/${BINARY} /usr/local/bin/${BINARY} USER 65534 +# ENTRYPOINT instruction does not expand args from both ENV and ARG. +# Since variable defined with ENV is available at runtime it will be +# consumed this way. This also means it may be overridden by passing +# --env ENTRYPOINT=... to docker run ARG ENTRYPOINT=/usr/local/bin/${BINARY} +ENV ENTRYPOINT=${ENTRYPOINT} ENTRYPOINT ${ENTRYPOINT}