mirror of
https://github.com/containers/podman-compose.git
synced 2025-06-19 19:27:47 +02:00
Add support for --build-arg option
This commit is contained in:
parent
e8147e350b
commit
19733407b4
@ -1071,7 +1071,7 @@ def build_one(compose, args, cnt):
|
|||||||
if getattr(args, 'pull_always', None): build_args.append("--pull-always")
|
if getattr(args, 'pull_always', None): build_args.append("--pull-always")
|
||||||
elif getattr(args, 'pull', None): build_args.append("--pull")
|
elif getattr(args, 'pull', None): build_args.append("--pull")
|
||||||
args_list = norm_as_list(build_desc.get('args', {}))
|
args_list = norm_as_list(build_desc.get('args', {}))
|
||||||
for build_arg in args_list:
|
for build_arg in args_list + args.build_arg:
|
||||||
build_args.extend(("--build-arg", build_arg,))
|
build_args.extend(("--build-arg", build_arg,))
|
||||||
build_args.append(ctx)
|
build_args.append(ctx)
|
||||||
compose.podman.run(build_args, sleep=0)
|
compose.podman.run(build_args, sleep=0)
|
||||||
@ -1364,6 +1364,8 @@ def compose_build_parse(parser):
|
|||||||
help="attempt to pull a newer version of the image", action='store_true')
|
help="attempt to pull a newer version of the image", action='store_true')
|
||||||
parser.add_argument("--pull-always",
|
parser.add_argument("--pull-always",
|
||||||
help="attempt to pull a newer version of the image, Raise an error even if the image is present locally.", action='store_true')
|
help="attempt to pull a newer version of the image, Raise an error even if the image is present locally.", action='store_true')
|
||||||
|
parser.add_argument("--build-arg", metavar="key=val", action="append", default=[],
|
||||||
|
help="Set build-time variables for services.")
|
||||||
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
|
@ -1,7 +1,9 @@
|
|||||||
FROM busybox
|
FROM busybox
|
||||||
ARG buildno=1
|
ARG buildno=1
|
||||||
ARG httpd_port=80
|
ARG httpd_port=80
|
||||||
|
ARG other_variable=not_set
|
||||||
ENV httpd_port ${httpd_port}
|
ENV httpd_port ${httpd_port}
|
||||||
|
ENV other_variable ${other_variable}
|
||||||
RUN mkdir -p /var/www/html/ && \
|
RUN mkdir -p /var/www/html/ && \
|
||||||
echo "ALT buildno=$buildno port=$httpd_port `date -Iseconds`" > /var/www/html/index.txt
|
echo "ALT buildno=$buildno port=$httpd_port `date -Iseconds`" > /var/www/html/index.txt
|
||||||
CMD httpd -f -p "$httpd_port" -h /var/www/html
|
CMD httpd -f -p "$httpd_port" -h /var/www/html
|
||||||
|
@ -17,3 +17,9 @@ services:
|
|||||||
image: my-busybox-httpd2
|
image: my-busybox-httpd2
|
||||||
ports:
|
ports:
|
||||||
- 8000:8000
|
- 8000:8000
|
||||||
|
test_build_arg_argument:
|
||||||
|
build:
|
||||||
|
context: ./context
|
||||||
|
dockerfile: Dockerfile-alt
|
||||||
|
image: my-busybox-httpd2
|
||||||
|
command: env
|
||||||
|
Loading…
x
Reference in New Issue
Block a user