buildah
buildah copied to clipboard
Feature request - ${VAR_NAME:?} dockerfile syntax to error on unset variables
Description
Docker supports ${SOME_VAR:?} syntax, which will give an error at build if SOME_VAR is unset. I believe this is directly in the Dockerfile syntax, not via a shell. Buildah doesn't support this, so this feature request is to request support for this syntax.
Example:
Docker
FROM public.ecr.aws/docker/library/node:16-alpine as builder
ARG USERID
USER ${USERID:?}
docker build .
...
Step 3/3 : USER ${USERID:?}
failed to process "${USERID:?}": USERID: is not allowed to be unset
# exit 1
Buildah/Podman
Buildah/Podman don't support this syntax:
podman build .
...
Error: error resolving step {Value:user Next:0xc0002ae8c0 Children:[] Attributes:map[] Original:USER ${USERID:?} Flags:[] StartLine:5 EndLine:5}: Unsupported modifier (?) in substitution: ${USERID:?}
This is a genuinely useful feature, so my request goes beyond just for the sake of compatibility.
Extra Info
Output of podman version:
podman version 4.2.1
buildah version 1.27.1 (image-spec 1.0.2-dev, runtime-spec 1.0.2-dev)
Package info (e.g. output of rpm -q podman or apt list podman):
podman/unknown,now 4:4.2.1-0ubuntu22.04+obs57.1 amd64 [installed]
buildah/unknown,now 1.27.1-0ubuntu22.04+obs25.1 amd64 [installed]
Have you tested with the latest version of Podman and have you checked the Podman Troubleshooting Guide? (https://github.com/containers/podman/blob/main/troubleshooting.md)
Yes/No Latest version in the kubic repo, haven't tried building from master.
Additional environment details (AWS, VirtualBox, physical, etc.):
Docker version for comparison:
Docker version 20.10.18, build b40c2f6
Hi @jwhitaker-swiftnav , Thanks for creating the issue.
I was unable to find any formal documentation on docker side for this, but I think we can implement this at imagebuilder. @nalind Any thoughts ? Since this is not a documented behavior on docker.
A friendly reminder that this issue had no activity for 30 days.
If this is a legitimate Dockerfile then we should support it. Whether it is documented or not. (Well maybe not if it is considered experimental)
@edsantiago Is this a special Bashism?
It's a common bashism; I have no knowledge of docker's level of support for it.
Parameter Expansion
${parameter:?word}
Display Error if Null or Unset. If parameter is null or unset, the
expansion of word (or a message to that effect if word is not present) is
written to the standard error and the shell, if it is not interactive, exits.
Otherwise, the value of parameter is substituted.
Seams reasonable.
@rhatdan @edsantiago Importantly, this is not a Bashism, but standard/POSIX/SUS. It also works in practice in other shells, e.g., Ash.
@flouthoc any time to work on it?
A friendly reminder that this issue had no activity for 30 days.
@flouthoc any time to work on it?
I'll check this thanks.
A friendly reminder that this issue had no activity for 30 days.
@jwhitaker-swiftnav Thanks PR https://github.com/openshift/imagebuilder/pull/243 should close this.