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=../../../<path to any 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 <andrii.ostapenko@att.com>
This commit is contained in:
Andrii Ostapenko 2021-05-19 00:37:03 -05:00
parent 3f5c7efd81
commit 3ad8f34e3f
No known key found for this signature in database
GPG Key ID: F3E83668DBB223B3

View File

@ -37,5 +37,10 @@ ARG BINARY=airshipctl
ENV BINARY=${BINARY} ENV BINARY=${BINARY}
COPY --from=builder /usr/src/airshipctl/bin/${BINARY} /usr/local/bin/${BINARY} COPY --from=builder /usr/src/airshipctl/bin/${BINARY} /usr/local/bin/${BINARY}
USER 65534 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} ARG ENTRYPOINT=/usr/local/bin/${BINARY}
ENV ENTRYPOINT=${ENTRYPOINT}
ENTRYPOINT ${ENTRYPOINT} ENTRYPOINT ${ENTRYPOINT}